简体   繁体   中英

htaccess regex wildcard redirects overriding other redirects

I currently have the following redirects in htaccess, and I need to add two new redirects. Though it appears the last wildcard redirect is overriding the two new redirects which I am trying to add. How do I correct this? Any suggestions? Thank you.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^mydomain.com

RewriteRule (.*) http://www.mydomain.com/ $1 [R=301,L]

RewriteRule ^.*.(jpe?g|gif|png|bmp|ico|swf|gz|xml|htm?l|pem|txt)$ - [L]

RewriteCond %{SCRIPT_FILENAME} !^apanel/*

RewriteRule ^(.*) process.php [L]


And the new redirects I am trying to add are as follows:

RewriteRule ^cs/(.*.css) /shared.php?type=css&files=$1

RewriteRule ^jscript/(.*.js) /shared.php?type=js&files=$1

Well as I read it your last RewriteCond/RewriteRule says "if the filename isn't in the 'apanel' folder redirect it to process.php and stop". Both of your new rules would match that rule first and mod_rewrite would stop processing further directives.

If you put your two new rules above your last Cond/Rule combo and use the [L] flag they should work properly....

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