Home  >  Article  >  Backend Development  >  ThinkPHP通过URL重写隐藏应用的入口文件index.php

ThinkPHP通过URL重写隐藏应用的入口文件index.php

WBOY
WBOYOriginal
2016-06-23 13:39:291493browse

我用的是apache


[ Apache ]

httpd.conf配置文件中加载了mod_rewrite.so模块,去掉#号。 AllowOverride None 将None改为 All,所有的都修改不然会报404。 把项目URL模式设置为2。'URL_MODEL' => 2, 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

<IfModule mod_rewrite.c>  RewriteEngine on  #如果目录存在就直接访问目录不进行RewriteRule   RewriteCond %{REQUEST_FILENAME} !-d  #如果文件存在,就直接访问文件,不进行下面的RewriteRule.(不是文件或文件不存在就执行重写)   RewriteCond %{REQUEST_FILENAME} !-f  #所有找不着实际路径的文件,统一交给index.php处理   RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule> 



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn