关于lnmp和iis7去掉index.php的方法
lnmp
找到要去掉的域名的config文件 以下是一个示例路径:
vim /usr/local/nginx/conf/vhost/对应域名的config文件
打开便看到sever标签,在其里面加上以下代码
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
保存重启nginx服务,指令:systemctl restart nginx
新建一个.htaccess文件,把以下代码复制粘贴进去,保存放在对应域名的根目录。
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
如果上面的还没生效,如果上面的生效即可略过。
就打开刚刚保存的配置文件把 include enable-php.conf
去掉注释;添加下面代码
include enable-php-pathinfo.conf;
iis7
1、打开配置文件(如:httpd.conf),找到你网站根目录的配置,将AllowOverride这项改为all
Options Indexes FollowSymLinks
AllowOverride all(----这个----)
Require all granted
</Directory>
2.重启服务之后新建一个web.Config文件,把以下代码复制粘贴进去,发在对应域名的根目录。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WPurls" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>