Rewrite rule for subdomains

淺唱寂寞╮ 提交于 2019-12-02 09:58:47

A RewriteRule with a target on another server will always do a redirect

Absolute URL
If an absolute URL is specified, mod_rewrite checks to see whether the hostname matches the current host. If it does, the scheme and hostname are stripped out and the resulting path is treated as a URL-path. Otherwise, an external redirect is performed for the given URL. To force an external redirect back to the current host, see the [R] flag below.


To map the URL http://example.com/app.php into your subdomains without redirecting, you might try the P|proxy flag

RewriteRule ^(.*)$ http://example.com/app.php/$1 [P,QSA]

Also keep the final note in mind

Note: mod_proxy must be enabled in order to use this flag.

Usually, this can be done by

a2enmod proxy proxy_http

If the target URL is https://..., you must also enable mod_proxy_connect, and activate SSL in your main or virtual host config with SSLProxyEngine

SSLProxyEngine on

Depending on your needs, ProxyPass might be a viable solution too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!