.htaccess htaccess和重写我的URL
我正在尝试使用.htaccess组织我的网站,我希望执行以下配置:.htaccess htaccess和重写我的URL,.htaccess,url-rewriting,.htaccess,Url Rewriting,我正在尝试使用.htaccess组织我的网站,我希望执行以下配置: 主站点的URL必须是beta.example.com/portal/ 其他网站应位于beta.example.com/othersite/ 如果用户访问beta.example.com,他们应该被重定向到301 beta.example.com/portal/ beta.example.com/portal(不带尾随斜杠)应重定向到beta.example.com/portal/ /portal/不是服务器上的物理文件路径。我
- 主站点的URL必须是beta.example.com/portal/
- 其他网站应位于beta.example.com/othersite/
- 如果用户访问beta.example.com,他们应该被重定向到301 beta.example.com/portal/
- beta.example.com/portal(不带尾随斜杠)应重定向到beta.example.com/portal/
- /portal/不是服务器上的物理文件路径。我希望所有这些网站 放在一个文件夹中,比如/html/www/websites/
- 门户所在的文件夹不应位于其中 /html/www/websites/portal/,但我希望能够切换实时 在服务器上快速将站点升级到新版本(位于不同文件夹中), 不可见,没有任何停机时间。顺便说一下,这适用于所有站点
#RewriteBase / #should I use rewritebase or not?
/RewriteCond %{HTTP_HOST} ^beta.example.com$
RewriteRule (.*) websites/$1 [L,NC]
.htaccess文件位于/websites/文件夹中,也可能是另一个文件,也可能不在站点所在的文件夹中
RewriteBase /websites # or, not...
# rewrite the active site to the folder /portal_v1.0/
RewriteCond %{REQUEST_URI} ^/portal/
RewriteRule (.*) portal_v1.0/$1 [L]
# rewrite the root to /portal/
RewriteRule ^$ http://beta.example.com/portal/ [L,NC]
然而,我仍然不能让它完全按照我想要的方式工作。一个问题是beta.example.com/portal重定向到www.example.com/websites/portal/的内容,我不希望这样。救命啊!提前谢谢 不正确的重定向是因为:嗯,我明白了。对我来说有点奇怪,为什么它会重定向到www。而不是仅仅在URL中添加斜杠。。。