eZ Community » Forums » Install & configuration » Apache RewriteCond/Rule

Apache RewriteCond/Rule

Apache RewriteCond/Rule

Monday 05 October 2015 4:34:34 pm - 2 replies

I'm trying to do this:

All requests to http://x.y.com/path/* shall go to http://x.z.com/path/*

One (potential) problem here is that both x.y.com and x.z.com are ServerAlias(es) on the same Apache instance.

Background: We are using eZ Publish and need to redirect certain URLs from a mobile design to a "full" browser based design. We do not have responsive design so we are bound to use two different designs that matches host.

We do not do any redirects based on browser because we want the ability for the users to view both sites.

Tuesday 06 October 2015 1:02:36 am

So your rewrite conditions are:

if the hostname is x.y.com
and if the URI is /path/*
redirect to http://x.z.com/path/*

if you're using .htaccess and want a 301 redirect it would look like this:

RewriteCond %{HTTP_HOST} x\.y\.com
RewriteRule ^(path/.*) http://x.z.com/$1  [R, L]

See http://httpd.apache.org/docs/2.4/rewrite/remapping.html for a more in-depth guide.

Wednesday 07 October 2015 9:58:06 am

Hey Geoff and thanks for pointing me in the right direction happy.gif Emoticon

After trying and failing a bit I came up with the following solution:


RewriteCond %{HTTP_HOST} new06\.neitileu\.no

RewriteRule   "^/test/(.+)"  "http://new05.neitileu.no/test/$1"  [R,L]

Works like a charm happy.gif Emoticon


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from