简体   繁体   中英

Using URL REWRITE to redirect secondary domain to a folder on a hosting account

I have two domains and one hosting account. I want the new domain to point to a sub-folder in my hosting account.

I've made a "HOST A" redirection for the new domain, so now when i type SECONDARY.COM (for example) i reach the root of the hosting (the same as if i was typing PRIMART.COM).

I then added a .htaccess file with this content :

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^secondary\.co\.il$ [NC]
RewriteRule ^(.*)$ http://www.primary.il/secondary$1 [R=301,L]

But seems like it changes nothing - When i type SECONDARY.COM i still reach the root and not the folder ("secondary").

Maybe something about the syntax, can't find the problem.

I've been trying almost anything but with no success, ANY help would be greatly appreciated.

Thanks in advance.

How about this? Looks a lot like what you're looking for :). Footnote: for underneath example primary.com offcourse also has to be a subfolder, which in my opinion is "cleaner".

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST}  secondary.com$ [NC]
RewriteCond %{REQUEST_URI} !^/secondary.com/.*$
RewriteRule ^(.*)$  /secondary.com/$1 [L]

RewriteCond %{HTTP_HOST}  primary.com$ [NC]
RewriteCond %{REQUEST_URI} !^/primary.com/.*$
RewriteRule ^(.*)$  /primary.com/$1 [L] 

Source: http://www.techrepublic.com/article/rewriting-urls-to-host-multiple-domains-on-a-single-ip-address-with-apache/6042903

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM