S
S
Sergey2015-10-30 22:26:09
MODX
Sergey, 2015-10-30 22:26:09

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.

Tried this option:
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]

+ for correct operation, you need to add the .htaccess file with the code to the assets, connectors, core, manager folders:
RewriteEngine Off

IndexIgnore */*
<Files *.php>
    Order Deny,Allow
    Deny from all
</Files>

As a result, problems appear:
The admin panel does not open.
UPD
Empirically found out that this code affects the admin panel (the settings are not visible from the admin panel)
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

3 answer(s)
S
Sergey, 2015-10-31
@Derzaiii

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]

Z
zooks, 2015-10-30
@zooks

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]

In general, the train of thought is clear.

M
mih_max, 2015-11-02
@mih_max

I substituted my website instead of borneza.ru, but it still kicks me out on them. What the hell is this? O_O

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question