N
N
Nikita Guriev2019-12-23 12:53:18
htaccess
Nikita Guriev, 2019-12-23 12:53:18

Why does the CNC not work when accessed from www?

Tell me, please, I set up the CNC, it changes from site.ru/index.php?q=text to site.ru/text

But as soon as you enter from www (www.site.ru/index.php?q=text) it does not transforms. I don't know where to insert www. Tell me please.

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/

RewriteRule ^index\.(php|html|htm)$ https://site.ru [R=301,L]

RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

php_value default_charset utf-8
AddType 'text/html; charset=utf-8' .html .htm .shtml

# REDIRECT FROM WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]


It was just necessary to move the lines after #REDIRECT FROM WWW up, after RewriteBase /

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