.htaccess文件配置(去掉url里面的index.php)无效url后面加/
2014-12-12 08:55
447 查看
昨天把网站放到服务器(linux)上面了,之前是在本地的windows服务器上面运行的,配置的
url加上/
第一句,当请求的不是一个文件时(这个里面变量的和php全局变量SERVER里面的好像是一样的)
第二句,当请求的url不是以/结尾时
第三句,当请求的url不是以.html结尾时候
第四句,重定向到写的网址这个是正则匹配
再后面的就是省去index.php的操作了
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^xxx.com$ [NC] RewriteRule ^index.php(.*)$ http://www.xxx/xxxi$1 [R=301,L] #R强制重定向,并且HTTP的相应码为302 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>这个文件在本地的时候是生效的,会补全url也可以省去url里面的index.php,但是在移植到服务器上面之后,前面补全url的可以代码可以生效,但是后面省去index.php的代码不生效了,搞了半天,不知道怎么回事,后台把php的运行模式改成了apache模块模式运行(本来是fastcgi)就ok了,但是开始在本地的时候php就是以fastcgi模式运行的啊,为什么呢???
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^(.*)\/$ RewriteCond %{REQUEST_URI} !^(.*)(\.html)$ RewriteRule ^(.*)$ http://www.xxx.com/xxx/$1/ [L,R=301] RewriteCond %{HTTP_HOST} ^xxx.com$ [NC] RewriteRule ^index.php(.*)$ http://www.xxx.com/xxx/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
url加上/
第一句,当请求的不是一个文件时(这个里面变量的和php全局变量SERVER里面的好像是一样的)
第二句,当请求的url不是以/结尾时
第三句,当请求的url不是以.html结尾时候
第四句,重定向到写的网址这个是正则匹配
再后面的就是省去index.php的操作了
相关文章推荐
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- 修改apache配置文件去除thinkphp url中的index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- thinkphp 去掉URL 里面的index.php
- 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- 修改apache配置文件去除thinkphp url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- Ubuntu-server 下Apache2 配置.htaccess 隐藏thinkPHP项目index.php无效解决办法
- ThinkPHP中通过URL重写隐藏应用的入口文件index.php的相关服务器的配置
- 修改apache配置文件去除thinkphp url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- CI框架apache和nginx环境下面统一去掉路径URL后面的index.php
- apache2.2.21下配置url地址重写 去掉index.php
- nginx服务器去掉url中的index.php 和 配置path_info
- thinkphp在wamp 配置去掉url中index.php方法
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- 修改apache配置文件去除thinkphp url中的index.php
- 修改apache配置文件去除thinkphp url中的index.php
- apache的.htaccess文件同时实现HTTPS跳转及伪静态去掉index.php