简体   繁体   中英

Change App Domain Using htaccess

I have hosted a app on pagoda box, my app installation has a url like wm-app.pagodabox.com. I added a DNS alias for eg: app.com which gave me a IP to point my A record to. I did that, it works just fine.

The problem is now that I go to app.com it redirects the domain to wm-app.pagodabox.com.

Pagoda-Box says that I can use simple apache URL rewrites to fix this. I have never understood the rewrites. I have only used it for removing index.php from my URLs, code for which is widely available online. I wan't any user visiting my site to see app.com instead of wm-app.pagodabox.com

Here is what I have so far (I have a feeling I am wrong):

RewriteCond %{HTTP_HOST} ^wm-app.pagodabox.com[nc]
RewriteRule ^(.*)$ app.com/$1 [r=301,nc]

I appreciate all the help.

Thanks!

There where some minor errors in your code

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^wm-app\.pagodabox\.com [NC]
RewriteRule ^(.*)$ http://app.com/$1 [R=301]

# might work but not very likely
RewriteCond %{HTTP_HOST} ^app\.com [NC]
RewriteRule ^(.*)$ - [L]

This should almost work under normal circumstances, but it your case there is already something doing the redirect the other way around. So my guess it the above code, combined with the existing redirect, will result in a redirect-tennis-competition (redirect back and forth)

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