2014-04-25 91 views
1

我想重定向所有请求,除了像.html .js .jpg等...例如www.mydomain.com/products应该去/index.php?p=cats & s =汽车但www.mydomain.com/myproduct.html应该去www.mydomain.com/index.php?p=prod & s = myprod所有重定向到无限循环

我所有的重定向工作正常,但有一个问题。如果我请求没有查询字符串,它会下降到不定式循环 我的代码在这里。有不定式循环的解决方案吗?

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

RewriteCond $1 !\. 
RewriteRule ^(.*) index.php?p=cats&s=$1 

RewriteRule ^(.*).html$ index.php?p=prod-detail&p=$1 

回答

0

使用这种方式:

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^.]+?)/?$ index.php?p=cats&s=$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+?)\.html$ index.php?p=prod-detail&p=$1 [L,QSA] 
+0

谢谢你..它的作品。 – Yargicx

+0

不客气,很高兴它解决了。 – anubhava