Jump to content

Is mod_rewrite all or nothing


jsladek

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/104467-is-mod_rewrite-all-or-nothing/
Share on other sites

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.