Hello!

Please tell me what is wrong in the code? Why when I try to access the site via a link without WWW, I redirect to www.site.ru/index.php?q=sss/sss/sss instead of www.site.ru/sss/sss/sss

When I simply follow links from the WWW, everything works out properly.

Here is an example of my .htaccess.

AddDefaultCharset utf-8 php_flag magic_quotes_gpc Off php_flag register_globals 0 Options +FollowSymLinks RewriteEngine On RewriteBase / ############################################################################ #### Убираем повторяющиеся слеши (/) в URL #### ############################################################################ RewriteCond %{REQUEST_URI} ^(.*)/{1,}$ # Проверяем, повторяется ли слеш (//) более двух раз. RewriteRule . %1%2 [R=301,L] # Исключаем все лишние слеши. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) index.php?q=$0 [L,QSA] RewriteCond %{HTTP_HOST} ^site\.ru$ [NC] RewriteRule ^(.*)$ http://www.site.ru/$1 [R=301,L] ErrorDocument 404 /404.php Options -Indexes 

    1 answer 1

    Well, well .... he asked, he answered ....

    In general, this implementation helped:

     AddDefaultCharset utf-8 php_flag magic_quotes_gpc Off php_flag register_globals 0 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteRule ^(.+)/$ /$1 [R=301,L] RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC] RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ErrorDocument 404 /404.php Options -Indexes 

    First I changed the terms of the redirect to index.php, and also changed the rules in some places, it seems to work, I will still be testing ... but it seems to be roaming!

    • Just now I’ll turn to the address line parameters not through $ _GET [q '], but through $ _SERVER [' REQUEST_URI ']. - Andrei