powpow Posted April 28, 2012 Share Posted April 28, 2012 Hello Everyone, I started working on a "clean url" process about a week ago. I have watched several youtube videos, read blogs/tutorials/forums, and have even used a mod_rewrite generated script @ http://www.generateit.net/mod-rewrite/. All I have to show for it is less hair and a deeper appreciation for people who understand this kind of stuff. I am hosting my website through gatorhost this particular domain is a sub domain of my site and the file hierarchy is that the subdomain is a child of my site. here is the url i am working with: http://arianadev.rppdesigns.com/index.php?page=SS.php I want it to be cleaned so it reads : http://arianadev.rppdesigns.com/SS.php or http://arianadev.rppdesigns.com/page/SS.php This first snippet of code causes my site to result in a "Internal Server Error" htaccess snippet Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule ^([^/]*)$ /index.php?page=$1 [L] With the following code the site runs but the urls are the same. htaccess snippet Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule ^page/([^/]*)\.html$ /index.php?page=$1 [L] If any one could be of any assistance that would greatly be appreciated. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/ Share on other sites More sharing options...
requinix Posted April 28, 2012 Share Posted April 28, 2012 The first URL would be easy if /SS.php didn't actually exist (like it was in an include/ directory or something). RewriteEngine on # does not exist as a file RewriteCond %{REQUEST_FILENAME} !-f # does not exist as a directory RewriteCond %{REQUEST_FILENAME} !-d # rewrite any /*.php through index.php RewriteRule ^[^/]+\.php$ index.php?page=$0 [L] If it does exist then the second URL would be easier because then you could assume anything in /pages/ is supposed to go through /index.php. RewriteEngine on RewriteRule ^pages/(.*)$ index.php?page=$1 [L] And FYI, Your first try causes a loop. The first time through it will rewrite every file in the root to index.php. The next pass will rewrite index.php back onto itself. The next pass will do it again. And again. Contrary to popular belief, [L] does not stop rewriting entirely. The second one... I'm not sure what you expected it to do. The URL will still be "/page/file.html" - that won't change. Are you talking about how "/index.php?page=file.html" URL doesn't change? Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1341384 Share on other sites More sharing options...
powpow Posted May 2, 2012 Author Share Posted May 2, 2012 Thank you for the speedy response... The first URL would be easy if /SS.php didn't actually exist This is a call to the db, when I first set it up I decided to try by page name and for some reason decided to keep the file extension even though it is just a place holder in the db. I have updated my old naming convention to the following: Menu=Appetizers Menu=Specials Menu=SoupsSalads Menu=Entrèes Menu=VegOptions Menu=Desserts For this reason I updated your code example to the following RewriteEngine on RewriteRule ^Menu/(.*)$ index.php?Menu=$1 [L] However, my urls still stay in the same format: http://arianadev.rppdesigns.com/index.php?Menu=Appetizers when I would like http://arianadev.rppdesigns.com/Menu/Appetizers is there a way to problem shoot each step something like the following: is rewrite on? does it parse the url? does it take the menu name as an argument? Since I am hosting my site through hostgator I don't have my own personal httpd.conf file. I have been concerned since the beginning that rewrite is just not on. Any further assistance would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1342279 Share on other sites More sharing options...
requinix Posted May 2, 2012 Share Posted May 2, 2012 You have to link to the new URLs, not the old ones. In order: probably, yes, and I'm not sure what you're asking but the answer is probably "yes" too. Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1342333 Share on other sites More sharing options...
powpow Posted May 2, 2012 Author Share Posted May 2, 2012 awesome, the links work but I have lost all of my css and images. since a Menu and Appetizers directory doesn't exist how do I map out my other files? Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1342351 Share on other sites More sharing options...
requinix Posted May 3, 2012 Share Posted May 3, 2012 Use absolute links like Note the leading slashes. Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1342503 Share on other sites More sharing options...
powpow Posted May 3, 2012 Author Share Posted May 3, 2012 Great works perfectly thank you so much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/261757-mod-rewrite-internal-server-error/#findComment-1342604 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.