SanCi

Typecho开启伪静态并隐藏index.php
一、Apache1、Typecho伪静态规则此配置可以放在apache的conf文件中,或者放在网站根目录.hta...
扫描右侧二维码阅读全文
21
2018/04

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

一、Apache
1、Typecho伪静态规则
此配置可以放在apache的conf文件中,或者放在网站根目录.htaccess文件中。
目前sanci在用:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,E=PATH_INFO:$1]

# RewriteRule ^(.*)$ /index.php/$1 [L]
# RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

另一种写法

RewriteEngine On
# 下面是在根目录,文件夹要修改路径,如 /typecho/,同时 RewriteRule 也要跟着变
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

2、带 www 的跳转到不带www的

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.weidao.net
RewriteRule (.*) http://weidao.net/$1 [R=301,L]

3、不带 www 的跳转到带www的

RewriteEngine On
RewriteCond %{HTTP_HOST} ^san.ci
RewriteRule (.*) http://www.san.ci/$1 [R=301,L]

4、http跳转到https

   RewriteEngine On
   RewriteCond %{SERVER_PORT} !^443$
   RewriteRule ^/?(.*)$ https://%{SERVER_NAME}/$1 [L,R]

也可以这样写:

   RewriteEngine On
   RewriteCond %{HTTPS} !on
   RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

二、Nginx
如果还有问题,请参考:http://docs.typecho.org/servers?s%5B%5D=nginx

location / {
index index.html index.php;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
}

三、SEA

name: typecho
version: 1
#cron:
# - description: cron test
# url: index.php
# schedule: every 43 mins
# timezone: Beijing
handle:
- rewrite: if(!is_dir() && !is_file()) goto "index.php?%{QUERY_STRING}"

注:记得到后台永久链接设置里,启用地址重写功能。
rewrite.png


随机一言(显示内容与本文关)
Last modification:October 5th, 2018 at 09:33 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment