在开启伪静态前,不管用哪个文章路径,文章链接中间都会有一个/index.php/,看起来太长了。开启伪静态去掉之后看起来就会好很多。
启用教程
1.点击后台设置 - 永久链接,在永久链接设置里面启用
重写功能,在选择或填写一个你喜欢的自定义文章路径
保存。
2.如果出现在下方情况,需要配置一下服务器的伪静态
规则,然后在勾选仍然想启用此功能
保存即可
伪静态规则
Apache配置,直接新建一个.htaccess
文件,里面内容填写下方代码,上传至网站根目录
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
Nginx配置
server {
listen 80;
server_name yourdomain.com;
root /home/yourdomain/www/;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location ~ .*\.php(\/.*)*$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
access_log logs/yourdomain.log combined;
}