简体   繁体   English

htaccess子域重定向文件夹

[英]htaccess subdomain redirect folder

Here's what I'm trying to do. 这就是我想要做的。

When you type admin.example.com I want users to be redirected to example.com/admin/ but I would like the url in the address bar to remain admin.example.com if possible. 当您键入admin.example.com时,我希望将用户重定向到example.com/admin/,但如果可能的话,我希望地址栏中的网址保持为admin.example.com。

I searched some solution for that but not working : 我为此寻找了一些解决方案,但无法正常工作:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.example\.com$
RewriteRule ^ http://example.com/admin%{REQUEST_URI} [L,P]

This also not work ... Is there any other setting in domain control panel ? 这也行不通...域控制面板中是否还有其他设置?

Just enable mod_proxy in apache and then in the virtual host enter the following and restart apache. 只需在apache中启用mod_proxy,然后在虚拟主机中输入以下内容并重新启动apache。

ProxyPass / http://example.com/admin/ ProxyPassReverse / http://example.com/admin/ ProxyPass / http://example.com/admin/ ProxyPassReverse / http://example.com/admin/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM