【发布时间】:2021-12-08 03:37:16
【问题描述】:
我在 .htaccess 中添加了这段代码,用于从 url 中删除 .php 扩展名。我还编写了一个代码,用于使博客 url 像 https://url.com/posttitle 一样对 seo 友好
<IfModule mod_rewrite.c>
#removing extension from url
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#blog
#if the file with the specified name in the browser doesn’t exist, or the directory in the browser doesn’t exist then procede to the rewrite rule below
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*)$ blog_detail.php?id=$1 [QSA,L]
</IfModule>
我已经添加了主页之类的链接。
首页
在这种情况下如何从 url 中删除索引?
【问题讨论】:
-
大概您实际上并没有链接到
index.php,这仅适用于链接到旧 URL 的 SEO 和第三方?