.htaccess没有重定向到我期望的地方

时间:2013-02-07 01:19:24

标签: .htaccess redirect

1-我写了以下重定向,期待当这个网址

http://www.curtainrodstore.com/index.php?crn=234

输入后会重定向到

http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/

2-而是重定向到

http://www.curtainrodstore.com/?crn=243

3-注意缺少的

“的index.php”

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^curtainrodstore.com [NC]
RewriteCond %{REQUEST_FILENAME} index\.php
RewriteCond %{QUERY_STRING} crn=243
RewriteRule ^.*$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
</IfModule mod>

有没有人对它为什么不起作用有任何建议?

这是更新的尝试清单......

<IfModule mod_rewrite.c>
RewriteEngine On
#ATTEMPT 1
#RewriteCond %{HTTP_HOST} ^curtainrodstore.com [NC]
#RewriteCond %{REQUEST_FILENAME} index\.php
#RewriteCond %{QUERY_STRING} crn=243
#RewriteRule ^.*$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
#ATTEMPT 2
#RewriteRule ^index\.php\?crn=243$ http://curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
#ATTEMPT 3
#RewriteCond %{HTTP_HOST} ^www.curtainrodstore.com$ [NC]
#RewriteCond %{QUERY_STRING} ^crn=234$
#RewriteRule ^index\.php$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/? [R=301,L]
#ATTEMPT 4
#RewriteCond %{HTTP_HOST} ^curtainrodstore.com$ [NC]
#RewriteCond %{QUERY_STRING} ^crn=234$
#RewriteRule ^index\.php$ http://curtainrodstore.com/product-category/curtains-drapery/shower-curtains/? [R=301,L]
#ATTEMPT 5
#
</IfModule>

1 个答案:

答案 0 :(得分:2)

你可以试试这个:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?curtainrodstore.com [NC]
RewriteCond %{REQUEST_URI} index\.php  [NC]
RewriteCond %{QUERY_STRING} crn=234    [NC]
RewriteRule .* product-category/curtains-drapery/shower-curtains/? [R=301,L]

永久重定向

http://www.curtainrodstore.com/index.php?crn=234

要:

http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/

对于静音映射,请从R=301

中删除[R=301,L]

确保在任何测试之前清除浏览器的缓存