Reply
htaccess - Redirecting from a directory to a different domain
Old 03-04-2008, 08:37 PM htaccess - Redirecting from a directory to a different domain
Novice Talker

Posts: 6
I need to redirect visitors from olddomain.com/directory to newdomain.com. I've set up my htaccess with...

Redirect 301 /directory http://www.newdomain.com

... and it works, but if someone goes to olddomain.com/directory/news.htm, they go to that page. They don't get redirected.

What do I need to write so that if someone goes to any file in /directory they are sent to just newdomain.com?

Thanks,

Chimp
Chimpie is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-04-2008, 09:22 PM Re: htaccess - Redirecting from a directory to a different domain
Novice Talker

Posts: 6
Okay, its working, not exactly how I wanted, but better.

With the following written...

Redirect 301 /directory http://www.newdomain.com

... if I go to www.olddomain.com/directory it takes me to www.newdomain.com. That's fine.

But if I go to www.olddomain.com/directory/whatever.htm it takes me to www.newdomain.com/whatever.htm. This is okay for this site as the page will be the same.

For future use it would be nice to know how to go to from www.olddomain.com/directory/whatever.htm to just newdomain.com. I probably need to throw a wildcard in there, but I tried a lot of different things and I couldn't figure it out.
Chimpie is offline
Reply With Quote
View Public Profile
 
Old 03-05-2008, 01:02 AM Re: htaccess - Redirecting from a directory to a different domain
mtishetsky's Avatar
Super Spam Talker

Posts: 880
Location: Volendam, Netherlands
Redirect 301 /directory.* url
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-06-2008, 12:49 PM Re: htaccess - Redirecting from a directory to a different domain
css25's Avatar
Average Talker

Posts: 17
Name: Jerry
Location: Home
To redirect ALL files on your domain use this in your .htaccess file if you are on a unix web server:

redirectMatch 301 ^(.*)$ http://www.domain.com
redirectMatch permanent ^(.*)$ http://www.domain.com

You can also use one of these in your .htaccess file:

redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html
css25 is offline
Reply With Quote
View Public Profile Visit css25's homepage!
 
Reply     « Reply to htaccess - Redirecting from a directory to a different domain
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13296 seconds with 13 queries