欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

thinphp apache url重写有关问题

程序员文章站 2022-05-12 08:29:21
...
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

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)$ index.php/$1 [L]


# Turn on these settings to get A in yslow. :)
#
# 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
#

#
#
# AddOutputFilterByType DEFLATE text/html text/css application/javascript
#

#
# 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文件放到入口文件的同级目录下



RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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


thinphp apache url重写有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频