A
A
AlexPack2015-12-15 13:34:41
Search Engine Optimization
AlexPack, 2015-12-15 13:34:41

301 redirect with or without slash?

Good day to all!
Another question about 301 redirect.
The essence of the problem. There is a site and its test version, two sites have the same .htaccess file, with only one difference, the rewrite condition and rewrite rule have the corresponding domains for the redirect. On the test version, the redirect works fine, but on the production version of the site, the redirect only works when requesting an address without a slash at the end.
How to make a 301 redirect work anyway with or without a trailing slash?
I repeat, the .htaccess files are completely the same, and I don’t understand why the 301st works differently.

Options -Indexes
ErrorDocument 404 /404.php

php_flag allow_call_time_pass_reference 1
php_flag session.use_trans_sid off

#php_value display_errors 1

php_value mbstring.func_overload 2
php_value mbstring.internal_encoding UTF-8

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^site.ru$ [NC]
RewriteRule ^(.*)$ www.site.ru/$1 [R=301,L]

#RewriteCond %{REQUEST_FILENAME} -f [OR]
#RewriteCond %{REQUEST_FILENAME} -l [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteCond %{REQUEST_FILENAME} [\xC2-\xDF][\x80-\xBF] [OR]
#RewriteCond %{REQUEST_FILENAME} \xE0[\xA0-\xBF][\x80-\xBF] [OR]
#RewriteCond %{REQUEST_FILENAME} [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} [OR]
#RewriteCond %{REQUEST_FILENAME} \xED[\x80-\x9F][\x80-\xBF] [OR]
#RewriteCond %{REQUEST_FILENAME} \xF0[\x90-\xBF][\x80-\xBF]{2} [OR]
#RewriteCond %{REQUEST_FILENAME} [\xF1-\xF3][\x80-\xBF]{3} [OR]
#RewriteCond %{REQUEST_FILENAME} \xF4[\x80-\x8F][\x80-\xBF]{2}
#RewriteCond %{REQUEST_FILENAME} !/bitrix/virtual_file_system.php$
#RewriteRule ^(.*)$ /bitrix/virtual_file_system.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]

DirectoryIndex index.php index.html

ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question