重写动态子域

时间:2018-05-14 13:52:51

标签: apache .htaccess virtualhost

我已经在Apache 2.4.18中设置了动态子域,就像这样;

<Directory "/var/www/vhosts/*">
    AllowOverride All
</Directory>

<VirtualHost *>
    ServerAlias *.example
    VirtualDocumentRoot /var/www/vhosts/%-2+
    LogLevel rewrite:trace5

    ErrorLog /tmp/errors.log
    Alias /404.php /var/www/404.php
    ErrorDocument 404 /404.php
</VirtualHost>

/var/www/vhosts的每个文件夹中,我创建了以下.htaccess来重写文件夹中index.php的所有请求。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]

Options Indexes FollowSymLinks MultiViews
Require all granted

我如何将.htaccess合并到我的Apache站点配置中?我尝试将我的.htaccess的内容复制到我的Apache站点配置顶部的<Directory />部分,但最终出现了递归错误。

应该如何路由事物的示例;

my.domain.example -> /var/www/vhosts/my.domain/index.php
my.domain.example/hello -> /var/www/vhosts/my.domain/index.php/hello
test.example -> /var/www/vhosts/test/index.php
test.example/world -> /var/www/vhosts/test/index.php/world

0 个答案:

没有答案
相关问题