Home Backend Development PHP Problem Typecho method to remove index.php

Typecho method to remove index.php

Sep 30, 2020 am 10:13 AM
index.php typecho

typecho去掉index.php的方法:首先配置服务器的rewrite规则;然后修改nginx以及apache配置;最后在后台配置typecho伪静态即可。

Typecho method to remove index.php

推荐:《PHP视频教程

typecho开启伪静态,去掉那个讨厌的index.php

Typecho后台设置永久链接后,会在域名后加上index.php,很多人都接受不了。例如如下网址:http://qqdie.com/index.php/archives/37/,但我们希望最终的形式是这样:http://qqdie.com/archives/37.html。那么我们如何做到这样的效果?

1.配置服务器的rewrite规则

如果在保存上述配置的时候,typecho无法自动配置,那么你可能需要手动配置服务器的rewrite规则。

Linux Apache 环境 (.htaccess):

<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目录,文件夹要修改路径
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Linux Apache 环境(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;
}
}
Windows IIS 伪静态 (httpd.ini):
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# 中文tag解决
RewriteRule /tag/(.*) /index\.php\?tag=$1
# sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# 内容页
RewriteRule /(.*).html /index.php/$1.html [L]
# 评论
RewriteRule /(.*)/comment /index.php/$1/comment [L]
# 分类页
RewriteRule /category/(.*) /index.php/category/$1 [L]
# 分页
RewriteRule /page/(.*) /index.php/page/$1 [L]
# 搜索页
RewriteRule /search/(.*) /index.php/search/$1 [L]
# feed
RewriteRule /feed/(.*) /index.php/feed/$1 [L]
# 日期归档
RewriteRule /2(.*) /index.php/2$1 [L]
# 上传图片等
RewriteRule /action(.*) /index.php/action$1 [L]
Copy after login

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;
    }
Copy after login

apache 配置

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
Copy after login

2.后台配置typecho伪静态

如图,在typecho后台,开启伪静态,并选择你喜好的url形式:

Typecho method to remove index.php

具体操作,根据本人实际操作如下

我的虚拟主机是apache的,在网站根目录找到.htaccess,有的没有可能是设置了隐藏文件,显示隐藏文件就能看到了。

然后编辑.htaccess文件,加入上文中对应的apache配置代码保存。然后去typecho程序后台,设置>永久链接,按照上文中图片的设置,保存即可。

The above is the detailed content of Typecho method to remove index.php. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to build a social media website with PHP and Typecho How to build a social media website with PHP and Typecho Jul 22, 2023 am 11:40 AM

How to build a social media website using PHP and Typecho With the rise of social media, more and more people want to have a social media website of their own. One way to build a social media website is to use PHP and Typecho, two open source tools. PHP is a scripting language widely used in web development, while Typecho is a small, easy-to-use, and secure blog system that is not only powerful but also convenient for secondary development. Below I will introduce how to use PHP and

How to use PHP and Typecho to build a website with multi-language support How to use PHP and Typecho to build a website with multi-language support Jul 21, 2023 pm 11:21 PM

How to use PHP and Typecho to build a website with multi-language support Introduction: With the development of globalization, building a website with multi-language support has gradually become a goal pursued by enterprises and individuals. As a popular programming language, PHP, combined with Typecho, an excellent PHP open source blog program, can easily build multi-language websites. This article will introduce how to use PHP and Typecho to build a website with multi-language support, and provide relevant code examples. 1. Install and configure Typecho first

How to implement website image upload function through PHP and Typecho How to implement website image upload function through PHP and Typecho Jul 21, 2023 pm 03:51 PM

How to implement the website image upload function through PHP and Typecho. In the trend of modern online social platforms, image sharing is a very popular way. The image upload function of the website is a must-have feature for many websites, allowing users to easily upload their own images and share them with others. This article will introduce how to implement the website image upload function through PHP and Typecho. Typecho is an open source PHP blog system, which is very suitable for building personal blogs and small websites. It is lightweight and easy to use

Discussion on PHP programming technology in Typecho Discussion on PHP programming technology in Typecho Jul 22, 2023 am 10:01 AM

Introduction to the discussion of PHP programming technology in Typecho: Typecho is a simple and efficient PHP blog engine, which is lightweight and easy to expand. This article mainly discusses PHP programming technology in Typecho, including commonly used PHP functions, database operations, file reading and writing, form processing, etc. And through code examples, it shows how to implement common functions in Typecho. 1. Application of PHP functions String processing String processing is one of the commonly used operations in PHP programming. in Type

How to use PHP and Typecho to dynamically generate a website navigation bar How to use PHP and Typecho to dynamically generate a website navigation bar Jul 22, 2023 pm 10:42 PM

How to use PHP and Typecho to dynamically generate a website navigation bar. The navigation bar is a very important part of a website. It can help users quickly locate the required pages and provide users with a good browsing experience. When making a website, we usually use PHP to dynamically generate the navigation bar. This article will introduce how to use PHP and Typecho to dynamically generate a website navigation bar, and attach code examples for readers' reference. Before starting, make sure you have Typecho installed and have created

How to implement website subscription function through PHP and Typecho How to implement website subscription function through PHP and Typecho Jul 21, 2023 pm 07:01 PM

How to implement website subscription function through PHP and Typecho With the rapid development of the Internet, more and more people are beginning to subscribe to their favorite websites in order to get updated content at any time. In order to meet user needs, website administrators need to provide a convenient subscription function. In this article, we will introduce how to use PHP and Typecho to implement the subscription function of the website. Typecho is a simple and fast open source blog system written in PHP language. It provides a convenient plug-in mechanism that allows developers to

PHP and Typecho implement innovative methods for content display websites PHP and Typecho implement innovative methods for content display websites Jul 22, 2023 pm 06:43 PM

PHP and Typecho are innovative ways to implement content display websites. With the rapid development of the Internet, websites have become an important platform for people to obtain information, communicate and display themselves. In order to meet different needs, developers continue to seek innovative ways to implement content display websites. This article will introduce an innovative method to implement a content display website using PHP and Typecho, with code examples attached. Typecho is a simple and easy-to-use open source blog engine. It is developed in PHP language and supports custom themes and plug-ins.

How to implement website anti-spam comment function through PHP and Typecho How to implement website anti-spam comment function through PHP and Typecho Jul 21, 2023 pm 03:25 PM

How to realize the anti-spam comment function of the website through PHP and Typecho. With the rapid development of the Internet, spam comments have become an important problem that troubles website operators. To solve this problem, we can use PHP and Typecho to implement the anti-spam comment function of the website, effectively filtering and preventing the occurrence of spam comments. Before we start, we need to make sure that you have Typecho installed and have a certain foundation in PHP programming. Below are the steps and code examples to implement the anti-spam feature on your website. Learn about trash

See all articles