如何使用 htaccess 删除 index.html index.php

发布于 2024-10-01 06:20:17 字数 382 浏览 1 评论 0原文

我的博客中有这些网址

http://myblog.com/news/post1/index.php
http://myblog.com/updates/post3/index.html
http://myblog.com/index.html
http://myblog.com/blog/post4/index.php

如何设置 .htaccess 以便所有网址都以“/”结尾

http://myblog.com/news/post1/
http://myblog.com/updates/post3/
http://myblog.com/
http://myblog.com/blog/post4/

提前致谢!

I have these urls in my blog

http://myblog.com/news/post1/index.php
http://myblog.com/updates/post3/index.html
http://myblog.com/index.html
http://myblog.com/blog/post4/index.php

How do I setup .htaccess so that all the urls will end with "/"

http://myblog.com/news/post1/
http://myblog.com/updates/post3/
http://myblog.com/
http://myblog.com/blog/post4/

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2024-10-08 06:20:17

要从 PHP 文件中删除 .php 扩展名:

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

如果您想从 html 文件中删除 .html 扩展名:

RewriteRule ^([^\.]+)$ $1.html [NC,L] 

或者参见这篇文章:

To remove the .php extension from a PHP file:

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

If you want to remove the .html extension from a html file:

RewriteRule ^([^\.]+)$ $1.html [NC,L] 

Or see this post:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文