T
T
theEternalStudent2016-07-07 13:32:43
Yii
theEternalStudent, 2016-07-07 13:32:43

What's wrong with my .htaccess?

RewriteEngine on
RedirectMatch 403 /\..*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
RewriteRule ^(.*)$ site.com/$1 [R=301,L]
The last block should redirect all links www to non-www, which is what it does. But for some reason, when you type www.site.com/category?id=246 for example , it redirects to site.com/index.php?id=246. The site works on yii, there are no similar routes there.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
theEternalStudent, 2016-07-07
@theEternalStudent

Alexey @alsopub Works
out RewriteRule first. index.php and only then RewriteRule ^(.*)$ site.com/$1 [R=301,L]
Move the block with redirect www -> without www to the top

E
Evgeny Bukharev, 2016-07-07
@evgenybuckharev

# RewriteEngine
<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

# Редирект на страницу без многократных /.
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

# Убираем несколько слешей в урле
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
# Убираем последний слеш в урле
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} (/+)$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
# Редирект со строчных букв на прописные
# Необходимо в VirtualHost добавить RewriteMap  lc int:tolower
# RewriteCond %{REQUEST_URI} [A-Z]
# RewriteRule ^(.*)$ /${lc:$1} [R=301,L]


# Блокируем рефер спам
RewriteCond %{HTTP_REFERER} simple-share-buttons\.com [NC]
RewriteRule .* – [F]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php


#в случае index.php|htm|html:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/ 
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTPS/ 
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]


</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question