教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php mvc使用htaccess隐藏index.php

php mvc使用htaccess隐藏index.php

发布时间:2017-11-26   编辑:jiaochengji.com
如何在php mvc框架中隐藏index.php,可能用的最多的就是使用htacces来实现了,本文通过实例加以说明,有需要的朋友参考下。

一个简单的php mvc,但是有的hosting无法通过 htaccess 正常隐藏 index.php 或 index.php?arg=。

解决方法,Htaccess代码:
 

复制代码 代码示例:
# Turn on URL rewriting 
RewriteEngine On 
 
# Installation directory 如果项目在非根目录的话,就填目录名,比如:/test/ 
RewriteBase /DIR_HERE/ 
 
# Protect application and system files from being viewed 
RewriteRule ^(application|modules|system) - [F,L] 
 
# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
 
# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php/$0 [PT,L] 
# or 
#RewriteRule .* index.php?arg=$0 [PT,L] 
 

将以上代码写到 .htaccess 文件,并放置项目根目录下,即可实现隐藏 index.php 或 index.php?arg=了。

您可能感兴趣的文章:
php mvc使用htaccess隐藏index.php
ThinkPHP利用.htaccess文件的Rewrite规则隐藏URL中的index.php
ubuntu隐藏index.php的方法
ubuntu10.10配置ZendFramework开发框架
PHP使用图片Etag判断用户的实例代码
php怎么改成html
301重定向代码(php apache)
php使用include加密路径的方法介绍
学习用php实现mvc简单框架
php实现简单MVC

关键词: htaccess  php mvc   
[关闭]
~ ~