开发者

Writing if else conditions in htaccess file

I am trying to rewrite with htaccess need to use if else block or any other for rewriting following url:

for this url http://domain.kp/subdirecory/productname i am able to rewrite perfectly but when i am trying to rewrite for only http://domain.kp/subdirecory/ it rewrites with below given route 开发者_开发问答parameter, but route parameter should be considered while we have a product name in url.

please help if anybody has come across this type of issue

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]


I'm not sure where you were placing your second rule, but the ordering of the rules does matter. If you place the following rule before your current one, it should redirect all requests for a single directory.

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^([^\/]*)\/$ /other.php?_param_=$1 [L,QSA]

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜