Jagarm Posted October 18, 2008 Share Posted October 18, 2008 Hello everyone, I am trying to write an MVC for my PHP web site, and I found this cool .htaccess code that directs all the request to index.php. So for example if one enteres www.somesite.com/music.php this will act like this www.somesite.com/index.php?display=music.php. This works great except I also have a CSS attached to the page and once the htaccess is enabled the css doesn't work. How can I tell the .htaccess that if it is a css then just process it normally. The following is the code: RewriteEngine on RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ index.php?display=$1 [L,QSA] Thanks all Quote Link to comment Share on other sites More sharing options...
corbin Posted October 18, 2008 Share Posted October 18, 2008 Try: RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*) index.php?display=$1 [L,QSA] That should forward anything that doesn't exist. I think the REQUEST_FILENAME conds aren't working correctly. Quote Link to comment Share on other sites More sharing options...
Jagarm Posted October 18, 2008 Author Share Posted October 18, 2008 Thanks alot corbin, It works like a charm. Appreciate for your reply Quote Link to comment Share on other sites More sharing options...
corbin Posted October 18, 2008 Share Posted October 18, 2008 No problem. Quote Link to comment Share on other sites More sharing options...
Jagarm Posted October 19, 2008 Author Share Posted October 19, 2008 How do I set to solve? or only moderators do that? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 19, 2008 Share Posted October 19, 2008 You should see a Topic Solved botton located near the bottom left of this post and just above the Quick Reply box Quote Link to comment Share on other sites More sharing options...
Jagarm Posted October 26, 2008 Author Share Posted October 26, 2008 I have the following .htaccess code that redirects all the request to PHP thus when doing berwari.net/movies it's like berwari.net/index.php?display=movies. RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*) index.php?display=$1 [L,QSA] Now I am trying to make it as follow berwari.net/movies/40 that means the following berwari.net/index.php?display=movies&n=40 that last one is optional it may sometimes be there whenever required. I would appreciate if somebody could help me out with this. Thanks Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 26, 2008 Share Posted October 26, 2008 Then you'll specify a second rewrite rule. RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d # matches berwari.net/movies/40 RewriteRule ^(.*)/([0-9]+) index.php?display=$1&n=$2 [L] # matches berwari.net/movies RewriteRule ^(.*) index.php?display=$1 [L] Quote Link to comment Share on other sites More sharing options...
Jagarm Posted October 26, 2008 Author Share Posted October 26, 2008 Thanks for the useful reply. Quote Link to comment 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.