美文网首页
tp5中虚拟域名配置

tp5中虚拟域名配置

作者: 大笨蛋就是我呀 | 来源:发表于2019-03-13 10:49 被阅读0次

    平时访问都是http://localhost/puclic/index.php/m/c/action,现在,如需要设置成

    y.com/m/c/action

    则需要进行以下设置

    1.找到apache下httpd-vhosts.conf文件,在末尾添加

    <VirtualHost *:80>

    DocumentRoot "c:/apache2.4/htdocs/puclic"      //根目录下的puclic目录

        ServerName y.com

    </VirtualHost>

    2.修改系统文件的hosts文件

    在末尾添加

    127.0.0.1 y.com

    3.在tp5的public目录下的.htaccess中添加

    <IfModule mod_rewrite.c>

      Options +FollowSymlinks -Multiviews

      RewriteEngine On

      RewriteCond %{REQUEST_FILENAME} !-d

      RewriteCond %{REQUEST_FILENAME} !-f

      RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

    </IfModule>

    4.让apache可以加载.htaccess文件,打开apache配置文件httpd.conf

    找到FollowSymLinks,将它的AllowOverride None修改为AllowOverride All,并去掉

    #LoadModule rewrite_module modules/mod_rewrite.so前的#

    至此,就可以已y.com/c/m/action的方法来

    访问了

    此问题发生在我想直接以y.com/images/1.png的形式访问图片却访问不了的情况下发生!

    相关文章

      网友评论

          本文标题:tp5中虚拟域名配置

          本文链接:https://www.haomeiwen.com/subject/dbqzpqtx.html