我已经在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