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 Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/ 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. Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-668804 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 Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-668806 Share on other sites More sharing options...
corbin Posted October 18, 2008 Share Posted October 18, 2008 No problem. Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-668817 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? Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-669432 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 Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-669459 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 Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-674811 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] Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-674934 Share on other sites More sharing options...
Jagarm Posted October 26, 2008 Author Share Posted October 26, 2008 Thanks for the useful reply. Link to comment https://forums.phpfreaks.com/topic/128989-solved-help-with-htaccess-request-directing/#findComment-675144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.