apache配置symfony并隐藏入口文件app.php

386次阅读
没有评论

——————————-

参考:

  1. 配置Web服務器
  2. apache url路由配置重写
  3. Apache URL重写规则(详解)
  4. symfony官网文档

——————————-

步骤:

  1. 按照上文1在apache配置文件httpd.conf里添加或放开LoadModule rewrite_module modules/mod_rewrite.so行配置の注释,启用rewrite模块。
  2. 并在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>

  3. 重启apache,完成。

注:我当前环境为wampserver php7.2+symfony3.4

此时在浏览器里访问sf.cn会直接访问Directory后面の目录并且隐藏了入口文件app.php,至于这个sf.cn当然是要在系统のhost文件里添加进去の啦,就和你のlocalhost这个域名一样。

facingscreen
版权声明:本站原创文章,由 facingscreen2022-08-12发表,共计893字。
转载说明:本文为搜栈网原创文章,除特殊说明外皆由CC-4.0协议发布,转载请注明出处,如有帮助欢迎打赏。
评论(没有评论)
验证码