eyoucms去掉index.php教程

针对不同服务器、虚拟空间,运行PHP的环境也有所不同,目前主要分为:Nginx、apache、IIS以及其他服务器。下面分享如何去掉URL上的index.php字符,记得在管理后台清除缓存,对于一些ECS服务器可能要重启nginx等服务!

 

【IIS服务器】

查看服务器的网站根目录下是否有 web.config 文件,将红色代码添加<system.webServer>与</system.webServer>之间。如果没有web.config文件,就将全部代码保存为web.config文件,上传到网站根目录下,记得去后台清除缓存,再从网站首页访问哦!

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="Imported Rule 1" enabled="true" stopProcessing="true">

<match url="^(.*)$" />

<conditions logicalGrouping="MatchAll">

<add input="{HTTP_HOST}" pattern="^(.*)$" />

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>

<action type="Rewrite" url="index.php/{R:1}" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

 

【Nginx服务器】

在原有的nginx重写文件里新增以下代码片段:

location / {

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=/$1 last;

break;

}

}

 

【apache服务器】
易优CMS在apache服务器环境默认自动隐藏index.php入口。
如果发现没隐藏,可以检查根目录.htaccess是否含有以下红色代码段:

<IfModule mod_rewrite.c>

Options +FollowSymlinks -Multiviews

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

</IfModule>

如果还是没有隐藏,可以尝试把红色第四行的代码改为加上个问号试试:  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
如果是宝塔用户,可以修改为:RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]

如果还是不行,继续查看apache是否开启了URL重写模块 rewrite_module , 然后重启服务就行了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值