Answer the question
In order to leave comments, you need to log in
How to remove duplicates using htaccess?
I'm trying to get rid of using htaccess:
1. index.php
2. remove the slash at the end
3. add www
I do this
Options -Indexes
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.site.ru/ [R=301,L]
RewriteCond %{HTTP_HOST} ^site\.ru
RewriteRule ^(.*)$ http://www.site.ru/$1 [R=301,L]
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,NE,R=301]
RewriteRule ^.htaccess$ - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index.php
ErrorDocument 404 /404
ErrorDocument 403 /403
Answer the question
In order to leave comments, you need to log in
problem with
Decided like this:
if (!empty($_SERVER['QUERY_STRING']) && empty($_SERVER['REDIRECT_URL'])) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question