[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Apache rewrite

Hi,

I'm having problems with an Apache rewrite rule. I have the below rewrite (snippet shown) however I need to add to have all traffic coming from a certain site, eg www.domain-x.com, sent to www.domain-y.com. My IT person is off on leave and I do not want to ruin his work!

Many thanks in advance.



RewriteEngine On

#RewriteCond %{HTTPS} !on
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}




# For UI Start
RewriteBase /

### For Index page
RewriteRule ^([a-zA-z0-9-_=+]+)/$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)/home$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)/home/$ index.php?memberdata=$1 [NC,L]
0
LetsLearn
Asked:
LetsLearn
  • 2
  • 2
1 Solution
 
xtermCommented:
In the VirtualHost directive for www.domain-x.com put:

RewriteEngine On
RewriteRule ^/(.*)         http://www.domain-y.com/$1 [L,R]

This will work if they just put the base site, or if they put /foo/bar.htm on the end, it will take them to the alternate site with the same path extension.
0
 
LetsLearnAuthor Commented:
sorry just one more question what if it is a only sub-directory to a sub-directory? eg www.domain-x.com/folder/home to www.domain-y.com/new_folder_name/home
0
 
xtermCommented:
Even easier!  The rule below will take them to the page they are requesting in /folder/home on the other end, but if you don't want that, simply remove the $1 on the end, and then requests for /folder/home/* will just go to www.domain-y.co/new_folder_name/home/
RewriteRule ^/folder/home/(.*)        http://www.domain-y.com/new_folder_name/home/$1 [L,R]

Open in new window

0
 
LetsLearnAuthor Commented:
Thanks for your help, much appreciated!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now