我的重定向有点问题。我的.htaccess中有大约2000次这样的重定向:
# index.php?cPath=24_60
RewriteCond %{QUERY_STRING} ^cPath=24_60
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки? [R=301,L]
除了这些之外一切正常:
# index.php?cPath=24_60_105
RewriteCond %{QUERY_STRING} ^cPath=24_60_105
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки/Дървени-подматрачни-рамки? [R=301,L]
# index.php?cPath=24_60_106
RewriteCond %{QUERY_STRING} ^cPath=24_60_106
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки/Метални-подматрачни-рамки? [R=301,L]
# index.php?cPath=24_60_107
RewriteCond %{QUERY_STRING} ^cPath=24_60_107
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки/Подматрачни-рамки-с-повдигащ-механизъм? [R=301,L]
#index.php?cPath=24_60_108
RewriteCond %{QUERY_STRING} ^cPath=24_60_108
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки/Подматрачни-рамки/Подматрачни-рамки-с-крака? [R=301,L]
他们都重定向到/Матраци/Подматрачни-рамки,我似乎无法确切地指出问题是什么。 我的其他规则可能很重要,所以这里是:
AddHandler application/x-httpd-php54 .php .php5 .php4 .php3
Options +FollowSymlinks
Options -Indexes
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteEngine On
RewriteBase /
all 2000+ 301 Redirects
...
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
就是这样。
答案 0 :(得分:1)
你的正则表达式中缺少锚点$
。使用以下方法修复它:
# index.php?cPath=24_60
RewriteCond %{QUERY_STRING} ^cPath=24_60(&|$)
RewriteRule ^index\.php$ /Матраци/Подматрачни-рамки? [R=301,L]
否则^cPath=24_60
也会匹配
cPath=24_60_105
cPath=24_60_106
cPath=24_60_107
等