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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.