.htaccess无法正常工作

时间:2013-01-29 08:02:36

标签: .htaccess mod-rewrite

我改变了.htacess文件,如下所示。

RewriteCond %{REQUEST_URI} (.*)product-list.php(.*)
RewriteRule (.*) www.example.com/swimming-pool/product-list\.php$1 [R=301,L]
RewriteCond %{REQUEST_URI} (.*)product-info.php(.*)
RewriteRule (.*)\?(.*)$ www.example.com/swimming-pool/product\-info\.php$2 [R=301,L]

当我要求

时,我只需要它

http://www.example.com/product-info.php?Applepc.html应重定向到

http://www.example.com/swimming-pool/product-info.php?Applepc.html

输出在URL字段中如下所示: -

  

www.example.com/swimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming -pool /产品list.phpswimming池/产品list.phpswimming池/产品list.phpswimming池/产品list.phpswimming池/产品list.phpswimming池/产品list.phpswimming池/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product-list.phpswimming-pool/product -list.phpswimming池/产品list.phpswimming池/产品list.phpproduct-list.php的?鲜花PG1-cid38.html

请告诉我错误的地方。

1 个答案:

答案 0 :(得分:1)

虽然您没有提及使用product-list.php的其他规则的目的是什么,但它包含在此规则集中。

你可以试试这个:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (product-list|product-info)\.php  [NC]
RewriteRule ^(.*)/?$  swimming-pool/$1 [R=301,L]

永久重定向此类网址

http://www.example.com/product-info.php?query

http://www.example.com/product-list.php?query

http://www.example.com/swimming-pool/product-info.php?query

http://www.example.com/swimming-pool/product-list.php?query

实际规则的问题似乎是它们正在产生循环。