conormacaoidh Posted August 27, 2009 Share Posted August 27, 2009 Hi, Can anyone see anything wrong with this: RewriteEngine on RewriteCond %{SCRIPT_NAME} !\.php RewriteRule ^cp[/]*?$ _cp/$1 [L] RewriteRule ^css/(.*)$ /_inc/css/$1 [L] RewriteRule ^js/(.*)$ /_inc/js/$1 [L] RewriteRule ^img/(.*)$ /_inc/img/$1 [L] RewriteRule ^files/(.*)$ /_user/files/$1 [L] RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] In this case only the last rule works. When I comment out the last rule then all of the other rules work! I don't know what is happening.... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/172167-mod_rewrite-problem/ Share on other sites More sharing options...
dreamwest Posted September 8, 2009 Share Posted September 8, 2009 They are directories: /_inc/js/$1 [L] Fake - left hand side Real - right hand side If the directory is real put htaccess in this directory /_inc/js/.htaccess Quote Link to comment https://forums.phpfreaks.com/topic/172167-mod_rewrite-problem/#findComment-914639 Share on other sites More sharing options...
Rebelrebellious Posted September 11, 2009 Share Posted September 11, 2009 I think that you need to stop the last one from happening to the requests that you have already changed. Even though you specified Last, the .htaccess file is reprocessed for each sub directory(I think) so: RewriteCond %{SCRIPT_NAME} !\.php RewriteRule ^cp[/]*?$ _cp/$1 [L] RewriteRule ^css/(.*)$ /_inc/css/$1 [L] RewriteRule ^js/(.*)$ /_inc/js/$1 [L] RewriteRule ^img/(.*)$ /_inc/img/$1 [L] RewriteRule ^files/(.*)$ /_user/files/$1 [L] RewriteCond $1 !^(_cp/|/_inc/css/|/_inc/js/|/_inc/img/|/_user/files/) RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] Also, if you want that first RewriteCond to stop all php requests then you may want add a rule to skip the next 5 RewriteRules. RewriteCond %{SCRIPT_NAME} !\.php RewriteRule - [s=5] RewriteRule ^cp[/]*?$ _cp/$1 [L] RewriteRule ^css/(.*)$ /_inc/css/$1 [L] RewriteRule ^js/(.*)$ /_inc/js/$1 [L] RewriteRule ^img/(.*)$ /_inc/img/$1 [L] RewriteRule ^files/(.*)$ /_user/files/$1 [L] RewriteCond $1 !^(_cp/|/_inc/css/|/_inc/js/|/_inc/img/|/_user/files/) RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] Quote Link to comment https://forums.phpfreaks.com/topic/172167-mod_rewrite-problem/#findComment-916862 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.