我的基本项目位于C:\xampp\htdocs\site.local\www
我可以运行我的应用http://site.local/basic/web/index.php
但我希望将其作为http://site.local/index.php
运行
我怎么解决这个问题?
我更改了httpd.conf
:
DocumentRoot "C:/xampp/htdocs/site.local/www/basic/web"
<Directory "C:/xampp/htdocs/site.local/www/basic/web">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
AllowOverride All
Require all granted
</Directory>
但它不起作用
答案 0 :(得分:0)
您的解决方案简称为虚拟主机。在C:\xampp\apache\conf\extra\httpd-vhosts.conf
中添加以下内容:
<VirtualHost 127.0.10.80:80>
##ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/site.local/www/basic/web"
ServerName site.local
ErrorLog "logs/site.local.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
然后,以管理员的身份运行记事本,然后打开C:\Windows\System32\drivers\etc\hosts
中的 hosts 文件,并在其末尾添加以下行:
127.0.10.80 site.local
保存这两个文件并重新启动Apache Server并恢复默认的.httaccess
。
注意:IP 127.0.10.80称为内部环路IP,专用于本地托管。它可以是以127开头的任何其他值,例如127.0.0.1(默认值)