在APACHE服务器上的访问方式上去除index.php nginx去掉index.php
2014-11-09 16:30
656 查看
在APACHE服务器上的访问方式上去除index.php
在APACHE服务器上的访问方式上去除index.php
下面我说下 apache 下 ,如何 去掉URL 里面的 index.php
例如: 你原来的路径是: localhost/index.php/index
改变后的路径是: localhost/index
1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉
2.在APACHE里面去配置 ,将里面的AllowOverride None都改为AllowOverride All
注意:修改之后一定要重启apache服务。
3.确保URL_MODEL设置为2, (url重写模式)
在项目的配置文件里写
return Array(
‘URL_MODEL’ => ’2′,
);
4 .htaccess文件必须放到跟目录下
这个文件里面加:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
补充: windows 里面不能创建 .htaccess , 下面我说下创建方法
新建任何一个文件,然后打开, 点击另存为 (文件类型选择所有),这样就可以创建了
呵呵, 剩下的就是 你自己去测试了, 赶紧去试试把
以下为nginx去掉index.php
nginx在默认配置下首页是跳转不到index php的,需要利用URL重定位rewrite技术方可实现取消index php,本文将介绍一种利用rewrite解决该问题的方法!
apache下只要在全局配置文件中设置了缺省首页index.php就能实现直接到达index.php,但是nginx目前默认情况下只能到达index.html而不能访问到index.php,初期接触NGINX的er可能会觉得很困扰,下面来介绍一下这问题怎么借助URL重定位rewrite技术,才能实现缺省index.php时,跳转到index.php页面进行访问。
具体情况请看以下代码:
location / {
root /var/www/phpshuo.com/;
index index.html index.htm;
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
转载 http://www.phpshuo.com/show/13_7191.html
在APACHE服务器上的访问方式上去除index.php
下面我说下 apache 下 ,如何 去掉URL 里面的 index.php
例如: 你原来的路径是: localhost/index.php/index
改变后的路径是: localhost/index
1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉
2.在APACHE里面去配置 ,将里面的AllowOverride None都改为AllowOverride All
注意:修改之后一定要重启apache服务。
3.确保URL_MODEL设置为2, (url重写模式)
在项目的配置文件里写
return Array(
‘URL_MODEL’ => ’2′,
);
4 .htaccess文件必须放到跟目录下
这个文件里面加:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
补充: windows 里面不能创建 .htaccess , 下面我说下创建方法
新建任何一个文件,然后打开, 点击另存为 (文件类型选择所有),这样就可以创建了
呵呵, 剩下的就是 你自己去测试了, 赶紧去试试把
以下为nginx去掉index.php
nginx在默认配置下首页是跳转不到index php的,需要利用URL重定位rewrite技术方可实现取消index php,本文将介绍一种利用rewrite解决该问题的方法!
apache下只要在全局配置文件中设置了缺省首页index.php就能实现直接到达index.php,但是nginx目前默认情况下只能到达index.html而不能访问到index.php,初期接触NGINX的er可能会觉得很困扰,下面来介绍一下这问题怎么借助URL重定位rewrite技术,才能实现缺省index.php时,跳转到index.php页面进行访问。
具体情况请看以下代码:
location / {
root /var/www/phpshuo.com/;
index index.html index.htm;
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
转载 http://www.phpshuo.com/show/13_7191.html
相关文章推荐
- URL_MODEL 2 不能访问 在APACHE服务器上的访问方式上去除index.php
- 在APACHE服务器上的访问方式上去除index.php
- ubnutu 环境下 在APACHE服务器上的访问方式上去除index.php
- 在APACHE服务器上的访问方式上去除index.php
- 在APACHE服务器上的访问方式上去除index.php
- 在APACHE服务器上的访问方式上去除index.php
- 在Apache服务器上的访问方式上去除index.php
- 在apache服务器上的访问去除index.php
- Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
- codeigniter 去除index.php (nginx,apache) 通用方法
- apache服务器下php项目访问速度慢的原因原来是因为session保存方式为files?
- nginx服务器,访问时如何不直接显示index.php,而是显示目录
- codeigniter 去除index.php (nginx,apache) 通用方法
- CI框架apache和nginx环境下面统一去掉路径URL后面的index.php
- CodeIgniter如何去掉Index.php-apache服务器
- codeigniter 去除index.php (nginx,apache) 通用方法
- CI框架在Apache服务器下去掉URL中的index.php
- nginx服务器去掉url中的index.php 和 配置path_info
- CI框架在 nginx 服务器上配置 rewrite 去掉 index.php 的方法:
- apache 访问www.a.com/index.php/index 去除index.php