重定向非www和https根的子文件夹中 [英] redirect non-www and https to subfolder of the root
问题描述
我想使测试ENV这个网站。我对住在同一个网站,它是工作。
我试图重定向到做重定向到该usbfolder(OPS)的要求。 这是我写的,但迄今为止它听起来它重定向到根。 如果我删除它的工作原理,但以https https的事实并非如此。这听起来它重定向到根目录
RewriteEngine叙述上
的RewriteBase / OPS /
的RewriteCond%{HTTP_HOST} ^ dev.domain \ .CO \。英国$
的RewriteCond%{REQUEST_URI}!^ / OPS /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$ / OPS / $ 1 [L]
的RewriteCond%{HTTP_HOST} ^ dev.domain \ .CO \。英国$
重写规则^(/)?$ /OPS/index.php [L]
感谢大家的关注。由于@anubhava提到的问题是与我的文档根目录。我们恢复htaccess的什么以往任何时候了。并覆盖DOCUMENT_ROOT在页面的顶部,它是工作:
如果(strpos($ _ SERVER ['DOCUMENT_ROOT'],/无功/网络/网站/ dev的')!= FALSE){
// OPS(子文件夹)
$ _ SERVER ['DOCUMENT_ROOT'] ='/ OPS。
}
我想重写文档根htaccess的,如果它本来是可能的。没有办法,这是我想出了到目前为止的答案。
I am trying to make test env for this website. I have the same website on live and it is working.
I am trying to redirect the request to do the redirect to this usbfolder(OPS). This is what I wrote so far but it sounds it is redirecting to root. If I remove the https it works but with https it doesn't. It sounds it's redirected to root
RewriteEngine on
RewriteBase /OPS/
RewriteCond %{HTTP_HOST} ^dev.domain\.co\.uk$
RewriteCond %{REQUEST_URI} !^/OPS/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /OPS/$1 [L]
RewriteCond %{HTTP_HOST} ^dev.domain\.co\.uk$
RewriteRule ^(/)?$ /OPS/index.php [L]
Thank you all for your concern. As @anubhava mentioned the problem was with my document root. We revert back the htaccess to what ever it was. and overwrite the DOCUMENT_ROOT in top of the page and it is working:
if (strpos($_SERVER['DOCUMENT_ROOT'], '/var/www/websites/dev') !== false) {
// OPS(sub-folder)
$_SERVER['DOCUMENT_ROOT'] .= '/OPS';
}
I would like to over-write document root in htaccess if it would have been possible. any way this is the answer I came up with so far.
这篇关于重定向非www和https根的子文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!