LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-25-2010, 10:18 AM   #1
Spetnik
Member
 
Registered: Mar 2004
Posts: 40

Rep: Reputation: 15
Apache: Redirect to root


I know that I can use the Redirect directive in apache to redirect users to another domain with "Redirect permanent / http://www.newdomain.tld", but when I use that line the entire URL is preserved. For example, if a user tries to access "http://www.olddomain.tld/afile.txt" they will be redirected to "http://www.newdomain.tld/afile.txt". Is it possible to redirect all requests to the root of the new domain (http://www.newdomain.tld)?

Thanks
AJS

Last edited by Spetnik; 03-25-2010 at 10:41 AM. Reason: Solved - thanks!
 
Old 03-25-2010, 10:26 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Code:
RedirectMatch 301 .* http://www.newdomain.tld

Last edited by troop; 03-25-2010 at 10:29 AM.
 
Old 03-25-2010, 10:35 AM   #3
valen_tino
Member
 
Registered: Jan 2008
Posts: 105

Rep: Reputation: 28
You could achieve it with mod_rewrite with rules like this one on your apache http server which hosts www.olddomain.tld:

Code:
RewriteRule ^/$ http://www.newdomain.tld [L,R]
More info on mod_rewrite is here.
 
Old 03-25-2010, 10:40 AM   #4
Spetnik
Member
 
Registered: Mar 2004
Posts: 40

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by troop View Post
Code:
RedirectMatch 301 .* http://www.newdomain.tld
Thanks! You rock!
 
  


Reply

Tags
modrewrite, redirect, rewriterule


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Redirect Help! Jude Terror Programming 2 04-07-2009 11:47 AM
Apache 2 Redirect kmeyers Linux - Software 4 02-26-2009 07:13 AM
apache redirect mahmoud Linux - Newbie 3 01-13-2009 08:59 PM
redirect in Apache baslemmens Linux - Networking 6 09-02-2004 12:07 PM
apache redirect? fibbi Linux - Software 7 01-30-2004 10:41 PM


All times are GMT -5. The time now is 01:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration