简体   繁体   中英

.htaccess - RewriteRule

Ok I have the following .htaccess and it works however I can seem to change it to the way I need it.

here is the current .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|admin|system|images|tpl|js|lib|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.php?tpl=$1 [L]


Options +FollowSymlinks

I need to add the following

RewriteRule ^(.*)/(.*)$ /index.php?cat=$1&tpl=$2 [L]

So i am wondering how do I get that rule to work? as when I add it it does not.

So if you want to add a rule that will handle all requests except the first one that matches the RewriteCond And those would be split into /?

I think something like this would work. Please note that I changed the $1 to ${REQUEST_URI} in your rewrite condition

RewriteEngine on
RewriteCond ${REQUEST_URI} !^(index\.php|admin|system|images|tpl|js|lib|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.php?tpl=$1 [L]

RewriteRule ^([^/]*)/?(.*)?$ /index.php?cat=$1&tpl=$2 [L]

Options +FollowSymlinks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM