Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess和重写我的URL_.htaccess_Url Rewriting - Fatal编程技术网

.htaccess htaccess和重写我的URL

.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/不是服务器上的物理文件路径。我

我正在尝试使用.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/不是服务器上的物理文件路径。我希望所有这些网站 放在一个文件夹中,比如/html/www/websites/
  • 门户所在的文件夹不应位于其中 /html/www/websites/portal/,但我希望能够切换实时 在服务器上快速将站点升级到新版本(位于不同文件夹中), 不可见,没有任何停机时间。顺便说一下,这适用于所有站点
我目前正在处理两三个.htaccess文件:一个在根目录(www.)中,它将beta.example.com指向文件夹/网站/

#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中添加斜杠。。。