开发者

Writing if else conditions in htaccess file

开发者 https://www.devze.com 2023-03-03 16:57 出处:网络
I am trying to rewrite with htaccess need to use if else block or any other for rewriting following url:

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

精彩评论

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