jsladek Posted May 6, 2008 Share Posted May 6, 2008 Hello I have a domain that I would like like to use ugly URLs and also pretty urls in the same directory. If I use mod_rewrite will it rewrite all urls or just the ones that match the rewrite rule? What I mean by this is I would like to use. http://www.yourwebsite.com/index.php?pg=login and also http://www.yourwebsite.com/drexel The first link will just function normally but the second would rewrite to something like the following http://www.yourwebsite.com/public.php?orginization=drexel I'm looking into mod_rewrite to accomplish this. Will it work for me or am I barking up the wrong tree? Thanks, John btw, it seems that myspace works similar. Unless they actually create a directory for each user and actually store the html content there as if it were its own site. Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/ Share on other sites More sharing options...
HaLo2FrEeEk Posted May 7, 2008 Share Posted May 7, 2008 Mod Rewrite is typically to take dynamic pages and make them look static. So you'd want to take http://www.yourwebsite.com/public.php?orginization=drexel And make it look like this http://www.yourwebsite.com/drexel So Google and other search engines can index it better. I redid my whole site, except my forum, but I still need help with a question that's been unanswered for weeks now. Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-534863 Share on other sites More sharing options...
trq Posted May 7, 2008 Share Posted May 7, 2008 If I use mod_rewrite will it rewrite all urls or just the ones that match the rewrite rule? It will only rewrite urls that match a rule. Accessing your pages directly/passing parameters will still function as per normal as long as you don't trigger any rewrite rule. Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-534956 Share on other sites More sharing options...
jsladek Posted May 8, 2008 Author Share Posted May 8, 2008 so the trick is to write a rule that only triggers on public.php (if that is what I use). Makes sense.. Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-536311 Share on other sites More sharing options...
jsladek Posted May 9, 2008 Author Share Posted May 9, 2008 Damn it, public.php is what the url needs to become, this will be a little trickier than I thought. -John Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-537117 Share on other sites More sharing options...
jsladek Posted May 14, 2008 Author Share Posted May 14, 2008 Here is a rule that I came up with that seems to work. RewriteRule ^([^/\.]+)/?$ /public.php?org=$1 it looks for a period in the filename Maybe it will help someone in the future. -john Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-540523 Share on other sites More sharing options...
jsladek Posted May 21, 2008 Author Share Posted May 21, 2008 Just a little additional info. I was shown another way to do this and it has apache actually check to see if the file or directory exists on the server. This is probably a better way. RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /public.php?sub=$1 [L] -Regards John Quote Link to comment https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/#findComment-546179 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.