Answer the question
In order to leave comments, you need to log in
How to set up a correct 301 redirect in modx via .htaccess?
Tell me how to properly set up a 301 redirect for the following options:
http://site.ru/ -> http://site.ru
http://site.ru/index , http://site.ru/index.php, http://site.ru/index.html -> http://site.ru
http://www.site.ru. -> http://site.ru.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^site.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L] # склейка домена с и без www
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://site.ru/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index http://site.ru/$1 [R=301,L]
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)index.php$ http://site.ru/$1 [R=301,L]
RewriteEngine Off
IndexIgnore */*
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index http://borneza.ru/$1 [R=301,L]
Answer the question
In order to leave comments, you need to log in
Found a solution:
To set up a redirect from
site.ru/index
site.ru/index.php
site.ru/index.html
www.site.ru/
site.ru/
to
site.ru
Insert in .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/
RewriteRule ^(.*)index\.(php|html|htm)$ $1 [R=301,L]
RewriteBase /
# склейка домена с и без www
RewriteCond %{HTTP_HOST} !^ site.ru$ [NC]
RewriteRule ^(.*)$ http:// site.ru/$1 [R=301,L]
# Переадресация с index
RewriteCond %{QUERY_STRING} ^(.*)index
RewriteRule ^(.*)$ http:// site.ru? [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
RewriteRule ^index\.html$ / [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question