Don't show the real URL

Discuss practical ways rearrange URLs using mod_rewrite.

Don't show the real URL

Postby Jint » Mon Jan 10, 2005 9:33 am

I have searched and searched over again, but haven't been able to find anything that worked yet...
What I want is something like this:

User type in:
http://www.mysite.com/aboutme/
and gets:
http://www.mysite/index.php?id=aboutme

I want to be able to controll whatever page is shown in the .htaccess file.
It could be done by simply using Redirect, like this:

Redirect /aboutme/ http://www.mysite.com/index.php?id=aboutme

But then the http://www.mysite.com/index.php?id=aboutme address shows up in the addressline, and I don't want it to.

Can someone please explain this to me, and I will be much happier.
Jint
 

Postby Caterham » Mon Jan 10, 2005 11:10 am

You can use mod_rewrite, if your server has the module mod_rewrite enabled and you are allowed to use it.

Google: what is mod_rewrite

Code: Select all
RewriteEngine On
# exit, if a folder/file below matches
RewriteRule ^(index\.php|images|scripts) - [L]
# rewrite every request exept if exited above to the index.php
RewriteRule ^(.+) index.php?id=$1 [L]


Bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Jint » Wed Jan 12, 2005 7:42 am

Sorry, I didn't make myself clear enough.
The Rewrite rule you gave did the trick, for what I asked for...

But I forgot something, and I don't know how to do this:

If I want to rewrite
www.domain.com/index.php?id=aboutme
to
www.domain.com/aboutme/

it is pretty simple...

But my idea is this:

I have the links:
www.domain.com/about/
www.domain.com/about/me/
www.domain.com/about/thesite/
www.domain.com/contact/
www.domain.com/contact/email/
www.domain.com/contact/mailform/
www.domain.com/contact/guestbook/

and it shout point the user to:

www.domain.com/index.php?id=about
www.domain.com/index.php?id=me
www.domain.com/index.php?id=thesite
www.domain.com/index.php?id=contact
www.domain.com/index.php?id=email
www.domain.com/index.php?id=mailform
www.domain.com/index.php?id=guestbook

Can that be done in some way?
mod_rewrite or not...
Jint
 

Postby Caterham » Wed Jan 12, 2005 10:07 am

I think this should do it:
Code: Select all
RewriteEngine On
RewriteRule ^(index\.php|images|scripts) - [L]
RewriteRule ^(?:(?:.*)/)?([^/]+)/?$ /index.php?id=$1 [L]


Bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 18 guests

cron