5

All i want to do is to rewrite url from www.exaple.hu to www.exaple.cz/hu. So under address www.exaple.cz/hu is displayed content from adress www.exaple.hu.

So when user type www.exaple.cz/hu, user is not redirected to www.exaple.hu but content from www.exaple.hu is displayed under domain www.exaple.cz/hu (so in adress bar is www.exaple.cz/hu).

anubhava
  • 761,203
  • 64
  • 569
  • 643
born2fr4g
  • 1,290
  • 4
  • 27
  • 38

3 Answers3

9

You will need to enable mod_proxy in your Apache config for that. Once mod_proxy is enabled, enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.exaple\.cz$ [NC]
RewriteRule ^(hu)/?$ http://www.exaple.$1 [L,P,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Ok, maybe my explanation was bad;) So when user type www.exaple.cz/hu, user is redirected to www.exaple.hu but in address bar there is still www.exaple.cz/hu not www.exaple.hu. – born2fr4g May 04 '12 at 20:25
  • Your explanation was correct and so was my answer :) My answer is indeed making sure that URL in browser stays `www.exaple.cz/hu` while content from `www.exaple.hu` is served (using mod_proxy). – anubhava May 04 '12 at 20:28
  • I would like to thank you for your help ;). And btw - do you know any good websites with tutorials or other learning materials on apache and mod rewrite ? Because, for example i dont know what those flags [NC] [L,P,NC] means (you call it flags or am i wrong ? ;)). Anyways - once again thx for help. – born2fr4g May 05 '12 at 10:37
  • 2
    You're welcome. Yes these are indeed called flags/options. L - Last, P - Proxy, NC - Ignore case comparison. Here is the official mod_rewrite doc: http://httpd.apache.org/docs/current/mod/mod_rewrite.html – anubhava May 05 '12 at 13:15
  • Btw how to enable mod_proxy ? i just need to uncomment lines with mod_proxy in httpd.conf file ? Is there a method to check, mod_proxy is enabled without having access to the httpd.conf ? (this is stage server where i cant access to this file). Is there any other way to do this ? ;) – born2fr4g May 13 '12 at 01:36
  • If you have PHP installed you can look at phpinfo() output to see what modules are enabled in Apache. – anubhava May 15 '12 at 15:39
2

Are the files for www.exaple.cz/hu and www.exaple.hu on the same server?

If yes, I would create a symbolic link so that www.exaple.cz/hu content directory is pointing to www.exaple.hu content directory.

For example if server A has directores:

  • /var/www/html/A which includes files for: www.exaple.cz/hu
  • /var/www/html/B which includes files for: www.exaple.hu

cd /var/www/html/

ln -s /var/www/html/B A

this way, you only have one source but link ways to get to the source.

If the two URLs are pointing to two diff servers, you can try mounting the two and using the slink Or.. include "www.exaple.hu" as a frame in www.exaple.cz/hu?

elle
  • 101
  • 1
  • 1
  • 4
1

If the files are on the same server, you may delete the add-on domain in (cpanel) and re-add the domain but this time select the other domain's working directory.

If the link structure of your domain is like:

<a href="/path/page">Link</a>

You can use the new site now without any problems.

Tarik
  • 4,270
  • 38
  • 35