Redirecting, but keeping the url the same

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Redirecting, but keeping the url the same

Post by Luke »

I didn't know where to post this because I'm not even sure if it's possible, but if so I'm betting it has something to do with apache...

Is it possible to make it so that if somebody types in http://www.mysite.com/cottages, it will redirect them to http://www.mysite.com/houses but keep the http://www.mysite.com/cottages in the url?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

+1... mod_rewrite is the way to go.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

oh yea... I was thinking that mod_rewrite would change the url... but I guess I hadn't thought real hard about it... thanks.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I am using these rules.. if I type in mysite.com/cottages/somepage.php, it drops me on mysite.com/accomodations/somepage.php and doesn't change the url, but if I type in mysite.com/cottages it redirects me to mysite.com/accomodations and it shows accomodations in the url... how come??

Code: Select all

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/cottages$ [NC]
RewriteRule (.*) /accomodations [L]

RewriteCond %{REQUEST_URI} ^/cottages/(.*) [NC]
RewriteRule (.*) /accomodations/%1 [L]
Post Reply