对不起,如果标题令人困惑。
我已经在我的本地机器上设置了一个虚拟主机。我已经设置http://dev映射到我的/htdocs/dev文件夹。在dnsmasq和.htaccess的帮助下,我进行了设置,以便将 的子域映射.dev到 .htaccess 中的文件夹/htdocs/dev。当我尝试访问时,这一切都很完美,例如,http://dev/file1.html或http://folder.dev/file2.html. 访问子文件夹时会出现问题。如果我404 Object not found尝试访问http://folder.dev/subfolder/或http://folder.dev/subfolder/file3.html.
我想它可以用.htaccess来解决,但我试过了,但我没能做到。这是我的/htdocs/dev/.htaccess样子:
# Default index file
DirectoryIndex index.php
# Interpret .html files as .php scripts
AddHandler php5-script .php .html
# Redirect subdomains to their respective folders
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.dev$ [NC]
RewriteRule !^([a-z0-9-]+)($|/) /%2%{REQUEST_URI} [PT,L]
我应该提到,如果我尝试访问http://dev/folder/subfolder/file3.html,没有问题。
如何设置诸如http://folder.dev/subfolder/指向的地址/htdocs/dev/folder/subfolder?