1

1-我写了以下重定向,期望当这个 url

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-注意丢失

“索引.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>

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

这是更新的尝试列表……</p>

<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>
4

1 回答 1

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]

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

于 2013-02-07T03:49:41.210 回答