born2fr4g
born2fr4g

Reputation: 1300

htaccess rewrite without redirect

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).

Upvotes: 5

Views: 13793

Answers (3)

Tarik
Tarik

Reputation: 4536

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.

Upvotes: 1

anubhava
anubhava

Reputation: 784998

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]

Upvotes: 10

elle
elle

Reputation: 101

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?

Upvotes: 2

Related Questions