Forum Moderators: phranque
I'm new to apache and mod_alias etc. My query is as follows - any help would be greatlt appreciated :
Users can access our site by specifying one of 2 URL's (slightly different due to language) - i.e they can access the same website using either of the example urls below -
[test.one.co.uk...] or
[zztest.zzone.co.uk...]
So DNS resolves both domains to the same application via the same http server (IHS).
We want to allow them to access the website application using only the domain name (not suffixed by /MySite/folder etc.)
I have changed the httpd.conf file as follows as an initial test :
RedirectMatch permanent ^/$ [test.one.co.uk...]
So now either url of
[test.one.co.uk...] or
[zztest.one.co.uk...]
will resolve to
[test.one.co.uk...]
What I need to do now, is maintain the orginal domain prefix in the redirected URL depending on which one they've used. Is there anyway we can code so that the destination redirect is prefixed with the domain that was first used, so that the browser url is always based on what they first used
I.e. -
[test.one.co.uk...] to
[test.one.co.uk...]
[zztest.one.co.uk...] to [zztest.zzone.co.uk...]
This is purely a superficial requirement as the way the redirect currently works the user is still accessing the application correctly, only the URL is displayed incorrectly if they first access via the different domain name.
Thanks!
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^((test¦zztest)\.example\.co\.uk)
RewriteRule ^/$ http://%1/MySite/folder/home.jsp [R=301,L]
RewriteRule ^/$ http://%{HTTP_HOST}/MySite/folder/home.jsp [R=301,L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(test¦zztest)\.example\.co\.uk
RewriteRule ^/$ /MySite/folder/home.jsp [L]
And again, the RewriteCond is only needed if more than just the two hostnames shown resolve to the current httpd.conf ServerName container.
Replace the broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies the pipe characters.
Jim