Home >Backend Development >PHP Problem >How to hide index.php in url

How to hide index.php in url

coldplay.xixi
coldplay.xixiOriginal
2020-08-10 11:37:363667browse

隐藏url中的index.php的方法:首先设置【'URL_MODEL'=>'2'】;然后根路径下建立一个【.htaccess】;接着将相关代码放到【.htaccess】中保存;最后将配置文件中【#】去除。

How to hide index.php in url

隐藏url中的index.php的方法:

第一步:

'URL_MODEL'=>'2'

第二步:根路径下建立一个.htaccess,可以通过一些软件比如EditPlus去另存为,windows可能不能直接创建

第三步:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

放到.htaccess中保存

第四步:开启Apache rewrite 模式 去配置文件中 

#LoadModule rewrite_module modules/mod_rewrite.so

去掉前面的#,AllowOverride None改为AllowOverride All ok

当然如果你不是Apache 是IIS就不能这样配了

相关学习推荐:php编程(视频)

The above is the detailed content of How to hide index.php in url. For more information, please follow other related articles on the PHP Chinese website!

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