简体   繁体   中英

.htaccess directory redirect

Our website's files are located at domain1.com/directory - I've just bought a new domain ( domain2.com ) and would like it to look as if the files are coming from the new domain, but actually pull content from domain1.com/directory

Can you please help me with the necessary code for the .htaccess file in the root directory of domain1.com so that domain2.com points to domain1.com/directory ?

Use:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain2.com [nc]
rewriterule ^(.*)$ http://www.domain2.com/directory/$1 [r=307,nc]

Thanks for the answer Adriano. In the end I used a combination of a CNAME DNS entry to point to the original domain and made the new domain an 'Add-on Domain' in the original domain's cPanel. All is working a-ok now.

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