sinister1 Posted March 2, 2009 Share Posted March 2, 2009 Hi, I am totally new to mod rewrite. Did a lot of digging around trough google. Seen a lot of posts on this website regarding rewriting. I have a website with a url structur like www.domain.com/index.php?page=shows i want to rewrite this to www.domain.com/_pages/shows is this possible and if so how do i do that? i've tried several options: Option 1: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?page=$1 [L] Option 2: RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.php RewriteRule ^(.*)/$ index.php?page=$1 [L] can anyone help me out here? Quote Link to comment https://forums.phpfreaks.com/topic/147568-making-wwwdomaincomindexphppageshows-rewrite-to-wwwdomaincom_pagesshow/ Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 "I have a website with a url structur like www.domain.com/index.php?page=shows i want to rewrite this to www.domain.com/_pages/shows" Technically you want domain.com/_pages/shows to be rewritten to domain.com/index.php?page=shows, not the other way around. Anyway: RewriteRule ^_pages/([^/]+)/?$ /index.php?page=$1 Oh, using ^(.*)$ doesn't make sense by the way. ^ is the begin anchor, and $ is the end anchor, so it doesn't make sense to allow any amount of anything and have start/end anchors. Also, (.*) would grab everything, so you would get index.php?page=_pages/shows. Quote Link to comment https://forums.phpfreaks.com/topic/147568-making-wwwdomaincomindexphppageshows-rewrite-to-wwwdomaincom_pagesshow/#findComment-775046 Share on other sites More sharing options...
sinister1 Posted March 3, 2009 Author Share Posted March 3, 2009 Oke thank you. Now the stylesheets arent used anymore. Some say that you have to add / for the css dir but this doesnt help neither. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/147568-making-wwwdomaincomindexphppageshows-rewrite-to-wwwdomaincom_pagesshow/#findComment-775501 Share on other sites More sharing options...
corbin Posted March 3, 2009 Share Posted March 3, 2009 Make sure you left RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d in there or it is possible that the requests to the CSS files are being rewritten. And yes, you will either need to rewrite CSS files (not recommended) or you will need to use absolute paths. Quote Link to comment https://forums.phpfreaks.com/topic/147568-making-wwwdomaincomindexphppageshows-rewrite-to-wwwdomaincom_pagesshow/#findComment-775831 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.