Answer the question
In order to leave comments, you need to log in
How to get rid of index.php in address using .htaccess in laravel?
Hello, I have a question about configuring .htaccess in Laravel.
Previously, my site was written by me on my own without CNC, eventually moved to Laravel. search engines in the list of indexed and searched pages have pages like site.ru/index.php?query=123 and do not throw them out of the index, these pages open the main one and are not redirected to /. Everything would be fine, they would eventually be deleted as duplicates, but the files registered via url() change their addresses to site.ru/public/index.php/build/css/style-abc123.css .
At the root of the site there is .htaccess with the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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>
Answer the question
In order to leave comments, you need to log in
.htaccesscool of course, but I would also like to take a look at the capital routs
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
# Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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>
Do I understand correctly that you had a site without CNC and with GET requests.
Now your urls are normal and you have redirected all old urls to the new site to the root ?
If so then
1. collect a complete list of old indexed urls.
2. Accordingly, in Excel, collect a list of new urls according to the principle old url new url.
3. Let's party girl here.
4. If you don’t care about SEO, then, as far as I understand, you have a problem that get requests remain in the URL.
So this is solved very simply ^(.*)/$ /$1\?
the question at the end of the redirect will delete all get requests, BUT BECAUSE you do not have a list of old get requests, your rule will cut off all local ones if they exist.
So go back to point 1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question