0

I have a htaccess file which grabs pretty much anything after the / sign and gives it to my index.php?i. This works perfectly but I want to take it one step closer and have the same htaccess use conditions. Currently this is the navigation method mysite.com/stuff/cat the htaccess simply grabs the string stuff/cat and my PHP can then load up contents about it. But what I want to do is: when the navigation is mysite.com/stuff/cat/images I want the htaccess to redirect to another file rather than my index.php. Is it possible to add some kind of If statement or condition in htaccess? (if string contains 'images' redirect to gallery.php?i=data)

here is my current code:

RewriteEngine On
RewriteOptions inherit
RewriteRule ^([a-zA-Z0-9/_\s'-()]+)$ index.php?i=$1
4

1 回答 1

1

您可以尝试以下操作(将其放在您的RewriteOptions:

RewriteRule ^([a-zA-Z0-9/_\s'-()]+)/images$ gallery.php?i=$1 [L]

我也建议L在您的其他规则中使用标志(如上)。

于 2013-04-18T14:27:04.137 回答