Доброго времени суток. Стояла простая задача: настроить редиректы в htaccess чтобы при открытии сайта "с www" он перебрасывал на адрес "без www" и при переходе на index.php перебрасывал на папку (адрес с "/" на конце). Погугли, нашел, заработало, но если при использовании ЧПУ в конец адреса дописать index.php (site.ru/catalog/section_code/element_code/index.php), то редиректа не будет и index.php так и останется в урле, а если в начале дописать www (www.site.ru/catalog/section_code/element_code/), то произойдет редирект на site.ru/bitrix/urlrewrite.php. Какие будет идеи почему это происходит? Вот весь htaccess:
Код
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag allow_call_time_pass_reference 1
php_flag session.use_trans_sid off
php_value memory_limit 50M
php_value post_max_size 50M
php_value upload_max_filesize 50M
php_value max_input_vars 10000
#php_value display_errors 1
#php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
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}]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
</IfModule>
а вот urlrewrite.php, который в корне сайта лежит:
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Цитата
но если при использовании ЧПУ в конец адреса дописать index.php (site.ru/catalog/section_code/element_code/index.php), то редиректа не будет и index.php так и останется в урле
А с чего вдруг в ЧПУ появится "index.php" ? Такого быть не должно
А все-таки жаль: иногда над победами нашими встают пьедесталы, которые выше побед. Булат Окуджава
Дмитрий Карпов пишет: Разместите код сразу после RewriteEngine On
Код
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http: //%1/$1 [R=301,L]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} ! /system/ .* [NC]
RewriteRule (.*?)index\.php /*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Цитата
но если при использовании ЧПУ в конец адреса дописать index.php (site.ru/catalog/section_code/element_code/index.php), то редиректа не будет и index.php так и останется в урле
А с чего вдруг в ЧПУ появится "index.php" ? Такого быть не должно