我在。htaccess中添加了这段代码,以便从url中删除。php扩展名。此外,我还编写了一个代码,使博客url像https://url.com/posttitle
<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>
我添加了像Home这样的链接。
回家的
如何从url中删除索引在这种情况下?
当导航到根目录(index.html/.php)时,你可以简单地在href
属性中使用"/"