简体   繁体   中英

Mapping wildcard subdomain to other host using htaccess

I host my wordpress on appfog but appfog doesn't allow wildcard subdomain yet. I decided to create an app on heroku and place the htaccess there, so any wildcard subdomain will rewrite to appfog.

How to make the URL sample-post.apps1.herokuapp.com/subtitle/... --> apps1.appfog.com/sample-post/subtitle/... using htaccess placed on heroku cedar?

Try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.apps1\.herokuapp\.com$ [NC]
RewriteRule ^(.*)$ http://apps1.appfog.com/%1/$1 [L,R]

If you don't want the URL in the browser's address bar to change (via the redirect, R flag in square brackets), then try changing the R to P (proxy). Apache would need to have mod_proxy loaded.

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