利用phpstudy配置虛擬主機
Listen 8080
<VirtualHost _default_:80>
DocumentRoot "D:\phpStudy\WWW"
<Directory "D:\phpStudy\WWW">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "D:\GitHub\TPVueTODO\public"
ServerName www.todo.com
ServerAlias todo.com
<Directory "D:\GitHub\TPVueTODO\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
注意是public目錄
url 重寫
但入口文件訪問時url總需要帶上index.php
,實際使用中可以使用apace的url重寫模塊完成自動加入index.php
。這個需要public下面的.htaccess
文件。如果碰到No input file specified.
可能需要修改下這個文件:
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
在默認情況下會導致No input file specified. 修改成:
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]