0

remove public/ from url I search and try to follow these step

  1. copy .htaccess from public/ and paste it into root /
  2. change server.php to index.php

  3. I try yo add

    RewriteEngine On RewriteRule ^(.*)$ public/$1 [L]

to my /.htaccess to remove url public It didnt work.

but if I remove that line It'work but all my Url link to css it's wrong path

NOTE :: I PUT all my Css into public/assets if I move folder assets  to my / It work but is their anyway If I dont want to move my floder assets

UPDATE .htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]


    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
test1321
  • 331
  • 1
  • 8
  • 23

1 Answers1

0

You can do it with 2 possible ways:

(1) Rename server.php in your Laravel root folder to index.php Copy the .htaccess file from /public directory to your Laravel root folder. For static files, you can change the htaccess file

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

(2) No need to do anything with htaccess.

1) copy index.php in public folder. remove/rename index.php in public.

2) paste in root folder of the project

3) Now open index.php and change 2 url paths like below. 
   require __DIR__.'/vendor/autoload.php';
   $app = require_once __DIR__.'/bootstrap/app.php';

That's all :)

In this way you need to change the js and css file paths by adding /public/ in those paths.

Hemamalini
  • 741
  • 7
  • 9