简体   繁体   中英

Hidden redirect domain name to a subfolder of an other DN using .htaccess or anything else

I want to redirect my domain name example.com to this domaine name: example2.com/new/mywebsite without changing the url(a hidden redirection) I tried several codes in stackoverflow but it didnt work for me..

Ps: example2.com is a different website, actualy i did 2 websites with the same dashbord in wordpress the same hosting but with a different domains name.

Example 1 that doesnt work:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^((www.)?)example1.com [NC]
RewriteRule ^folder/(.*)$ https://example2.com/new/website-a/$1 [R=301,L]

Example 2 that dosnt work too:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^website-a\.example1\.com$
RewriteRule ^(.*)$ https://example2.com/new/website-a/$1 [L,R=301]

Based on specifically what you're asking for in your first paragraph, this should work:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example1.com$ [NC]
RewriteRule ^(.*)$ https://example2.com/new/mywebsite [R=301,L]

But your examples are using different paths etc so make sure you update as needed.

Your Apache configuration files also need to be updated to ensure that AllowOverride All is set rather than AllowOverride None

This file needs to be put in the root folder of your example1 (old) domain. This is because the redirect is started when you visit the example1 site.

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