日期:2014-05-17  浏览次数:20495 次

thinphp apache url重写问题
例如:http://www.xxxx.com/index.php/Index/index/n/50
把这个url重写成:
http://www.xxxx.com/50
而不影响其他模块
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 这样只是把index.php去掉了,
访问首页的时候需要http://www.xxxx.com/50这样的效果
其他的还是:http://www.iwebo.dev/Setting/index 
只是去掉index.php

写成这样:
RewriteRule ^(.*)$ index.php/Index/index/n/$1 [QSA,PT,L]
会影响全部模块的访问
  在纠结,还请各位帮忙看看...

------解决方案--------------------
Options +FollowSymLinks +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule (.*)$ index.php/$1 [L]
</IfModule>

# Turn on these settings to get A in yslow. :)
# <IfModule mod_expires.c>
# ExpiresActive On
# ExpiresByType image/gif A2592000
# ExpiresByType image/jpeg A2592000
# ExpiresByType image/png A2592000
# ExpiresByType image/x-icon A2592000
# ExpiresByType application/javascript A2592000
# ExpiresByType application/x-shockwave-flash A2592000
# ExpiresByType text/css A604800
# </IfModule>
#
# <IfModule mod_deflate.c>
# AddOutputFilterByType DEFLATE text/html text/css application/javascript
# </IfModule>
#
# FileEtag none
------解决方案--------------------
通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果,通常需要服务器开启URL_REWRITE模块才能支持。

下面是Apache的配置过程,可以参考下:

1、httpd.conf配置文件中加载了mod_rewrite.so模块

2、AllowOverride None 将None改为 All

3、确保URL_MODEL设置为2

4、把.htaccess文件放到入口文件的同级目录下

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

</IfModule>