Apache的mod_rewrite:如何重定向到插件域本身的插件域的子文件夹的访问权限? [英] Apache mod_rewrite: how to redirect addon domains subfolder access to addon domain itself?
问题描述
在Apache服务器上的情况(目录树):
maindomain.com/
|
| _的.htaccess(只是一个空文件,这里没有规则)
|
| _ addondomain1.com/
| |
| | _的.htaccess
| | _的index.html
|
| _ addondomain2.com/
|
| _的.htaccess
| _的index.html
目前在addondomain1.com文件可以通过去观看为:
http://www.addondomain1.com/index.html
http://www.addondomain1.com/
http://www.addondomain1.com
http://www.maindomain.com/addondomain1.com/index.html
我想重定向所有请求:
HTTP://maindomain/addondomain1.com/some/path/anypage.html
(带或不带'WWW')
以相同的路径/文件,但在addondomain1.com并始终以'WWW':
http://www.addondomain1.com/some/path/page.html
为了尽量做到这一点,我放在 maindomain.com/addondomain1.com/.htaccess
这条规则:
的RewriteCond%{HTTP_HOST} ^!WWW \\ .addondomain1 \\ .COM $
重写规则^(。*)$http://wwww.addondomain1.com/$1[R = 301,L]
这一件作品差不多大,并重定向以及所有那些如下:
http://addondomain1.com/index.html>> http://www.addondomain1.com/index.html
http://www.addondomain1.com/>> http://www.addondomain1.com/
http://www.addondomain1.com>> http://www.addondomain1.com
http://www.maindomain.com/addondomain1.com/index.html>> http://www.addondomain1.com/index.html
http://www.maindomain.com/addondomain1.com/>> http://www.addondomain1.com/
http://maindomain.com/addondomain1.com/>> http://www.addondomain1.com/
但不幸的是去当:
http://maindomain.com/addondomain1.com
http://www.maindomain.com/addondomain1.com
注意上面的两个链接是没有最后的斜线,它重定向到:
http://www.addondomain1.com//server/root/path/addondomain1.com
我认为,正则表达式 ^(。*)$
越来越addondomain1.com作为一部分,因为最后的斜线丢失。你知道如何修复/ workaorund这个问题?
谢谢!
DirectorySlash关闭
Situation (directories tree) on an Apache server:
maindomain.com/
|
|_ .htaccess (just an empty file, no rule in here)
|
|_ addondomain1.com/
| |
| |_ .htaccess
| |_ index.html
|
|_ addondomain2.com/
|
|_ .htaccess
|_ index.html
Currently files in addondomain1.com can be viewed by going to:
http://www.addondomain1.com/index.html
http://www.addondomain1.com/
http://www.addondomain1.com
http://www.maindomain.com/addondomain1.com/index.html
I would like to redirect all requests:
http://maindomain/addondomain1.com/some/path/anypage.html
(with or without 'www')
to same path/file but under addondomain1.com and always with 'www':
http://www.addondomain1.com/some/path/page.html
In order to try to accomplish this, I placed in maindomain.com/addondomain1.com/.htaccess
this rule:
RewriteCond %{HTTP_HOST} !^www\.addondomain1\.com$
RewriteRule ^(.*)$ "http://wwww.addondomain1.com/$1" [R=301,L]
This one works almost great, and redirects well all the ones below:
http://addondomain1.com/index.html >> http://www.addondomain1.com/index.html
http://www.addondomain1.com/ >> http://www.addondomain1.com/
http://www.addondomain1.com >> http://www.addondomain1.com
http://www.maindomain.com/addondomain1.com/index.html >> http://www.addondomain1.com/index.html
http://www.maindomain.com/addondomain1.com/ >> http://www.addondomain1.com/
http://maindomain.com/addondomain1.com/ >> http://www.addondomain1.com/
But unfortunately when going to:
http://maindomain.com/addondomain1.com
http://www.maindomain.com/addondomain1.com
NOTE both links above are WITHOUT final slash, it redirects to:
http://www.addondomain1.com//server/root/path/addondomain1.com
I think the regexp ^(.*)$
is getting "addondomain1.com" as part because the final slash is missing. Do you know how fix/workaorund this issue?
Thanks!
DirectorySlash Off
这篇关于Apache的mod_rewrite:如何重定向到插件域本身的插件域的子文件夹的访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!