分享

thinphp apache url重写有关问题

 londonKu 2012-06-18
thinphp apache url重写问题
例如:http://www./index.php/Index/index/n/50
把这个url重写成:
http://www./50
而不影响其他模块
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 这样只是把index.php去掉了,
访问首页的时候需要http://www./50这样的效果
其他的还是:http://www.v/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>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多