子域友好的URL重定向多个文件夹

时间:2019-01-25 20:38:52

标签: apache .htaccess subdomain

我正在设置一个Apache服务器,并尝试在我的子域上创建友好的url。这是我的根文件夹中的文件夹的当前设置:

mydomain ----\
        |
        | - Folder A (folder_a) --\
        |       |
        |       | - Sub Site A(subfolder) --\
        |       |       | - index from sub folder
        |       |
        |       | index from Folder A
        |
        | - Folder B (folder_a) --\
        |       |
        |       | - Sub Site B(subfolder) --\
        |       |       | - index from sub folder
        |       |
        |       | index from Folder B
        |
        | - Folder C ...

因此,没有任何htaccess的有效网址是这些网址:

mydomain.com/folder_a/subfolder
mydomain.com/folder_b/subfolder

但是我正在尝试通过htaccess获得以下结果:

subfolder.mydomain/folder_a
subfolder.mydomain/folder_b

我尝试在根文件夹上进行此htaccess操作:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^subfolder\.domain\.com$
RewriteRule ^(\w+)/(.*)$ $1/subfolder/index.php$2 [L]

但这给我一个关于Apache的错误500。

还有例如folder_a中的htaccess:

RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.com$
# RewriteRule ^(.*)$ /folder_a/subdomain/index.php$1 [L,QSA]
# OR
RewriteRule (.*) http://subdomain.mydomain.com/folder_a/subdomain/index.php$1 [L]

它也给我错误500。

这是我当前用于这些域的虚拟主机文件:

<VirtualHost mydomain.com:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "W:/mydomaindevteste"
    ServerName mydomain.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

<VirtualHost subdomain.mydomain.com:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "W:/mydomaindevteste"
    ServerName subdomain.mydomain.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

Apache错误

[Mon Jan 28 07:54:12.433767 2019] [core:error] [pid 13208:tid 2032] [client 127.0.0.1:49993] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Mon Jan 28 07:54:12.433767 2019] [core:error] [pid 13208:tid 2032] [client 127.0.0.1:49993] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

0 个答案:

没有答案