문제

I want to redirect all request except like .html .js .jpg etc... For example www.mydomain.com/products should go to /index.php?p=cats&s=cars but www.mydomain.com/myproduct.html should go to www.mydomain.com/index.php?p=prod&s=myprod

my all redirects works fine but there is a problem. if i request without query string it's fall to infinitive loop my code is here. is there any solution for infinitive loop?

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

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

RewriteRule ^(.*).html$ index.php?p=prod-detail&p=$1
도움이 되었습니까?

해결책

Use it this way:

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top