-------------------------------
參考:
-------------------------------
步驟:
- 按照上文1在apache配置文件httpd.conf裏添加或放開LoadModule rewrite_module modules/mod_rewrite.so行配置的註釋,啓用rewrite模塊。
- 並在httpd.conf的最後一行添加如下類容(注意,要把projectName換成自己的項目):
<VirtualHost *:80> ServerName sf.cn ServerAlias www.sf.cn DocumentRoot E:/wamp64/www/projectName/web <Directory E:/wamp64/www/projectName/web> AllowOverride All Order Allow,Deny Allow from All </Directory> # uncomment the following lines if you install assets as symlinks # or run into problems when compiling LESS/Sass/CoffeeScript assets # <Directory E:/wamp64/www/projectName> # Options FollowSymlinks # </Directory> ErrorLog E:/wamp64/logs/project_error.log CustomLog E:/wamp64/logs/project_access.log combined </VirtualHost>
- 重啓apache,完成。
注:我當前環境爲wampserver php7.2+symfony3.4
此時在瀏覽器裏訪問sf.cn會直接訪問Directory後面的目錄並且隱藏了入口文件app.php,至於這個sf.cn當然是要在系統的host文件裏添加進去的啦,就和你的localhost這個域名一樣。