简体   繁体   中英

How to keep sub domain url instead of main domain url using htaccess?

I want to redirect to main domain from a sub domain, keeping the sub domain in the address bar using htaccess. I tried the following code

RewriteEngine On

RewriteCond %{HTTP_HOST} ^advertiser\.(xxxx\.com)$ [NC]
RewriteRule ^dashboard/?$ http://www.xxxx.com/en/index.php/publisher/dashboardadvtsr [L,NC,R=301]

By using this code, when we write 'advertiser.xxxx.com' in the address bar it redirect to the link ' http://www.xxxx.com/en/index.php/publisher/dashboardadvtsr '. I want to keep 'advertiser.xxxx.com' in address bar. How can I do this using htaccess?

Since both domains are in public_html you can use this rule:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^advertiser\.xxxx\.com$ [NC]
RewriteRule ^dashboard/?$ /en/index.php/publisher/dashboardadvtsr [L,NC]

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