生活

Typecho开启伪静态并隐藏index.php

Typecho后台设置永久链接后,会在域名后加上index.php,就比如我之前那篇文章

https://oxxx.cn/index.php/archives/6.html

强迫症表示真的很难受 ̄﹃ ̄
在网上找了很多教程,其中很多都是说在.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>

但是,我之前遇到过问题,可能是我这边的主机问题吧,开启地址重写功能后index.php并没有去掉,并且网站只能进入首页,点击文章显示500错误,今天终于把500错误的问题解决了,只要在伪静态下面添加下面的代码就可以解决启用地址重写500错误的问题:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-httpd-php application/x-javascript
# END

规则貌似的借用了wordpress的,只要能解决问题就成୧(๑•̀⌄•́๑)૭,如果有和我相同问题的不妨试一试哦

本文著作权归作者 [ SurGarfield ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。

发表留言

读者留言2

  1. Hmm is anyone else encountering problems with the pictures on this blog loading?
    I'm trying to determine if its a problem on my end or if it's the blog.
    Any feedback would be greatly appreciated.

  2. Kudos, Fantastic stuff!