非常基本的重写规则问题

发布于 2024-09-16 16:50:22 字数 621 浏览 3 评论 0原文

我有这个网址:

 http://www.mydomain.com/index.html

并且想要一个规则将上面的内容重写为:

 http://www.mydomain.com

换句话说,删除代码的index.html部分...

可能是这样的:

  RewriteRule ^$ index.html [NC]

谢谢

更新:

当您在中输入www.domain.com时浏览器,当然index.html被打开。 但是,当您单击我网站菜单上的“主页”时,会显示整个完整网址,这是我想避免的。因此,当点击“home”时,会显示 www.domain.com/index.html...但在地址栏中输入 www.domain.com 时不会显示,那么只会显示该内容,但无论如何都会出现 index.html。

所以是的,我需要这个:

www.domain.com/

不是这个:

www.domain.com/index.html

谢谢

I have this url:

 http://www.mydomain.com/index.html

And want a rule to rewrite the above into this:

 http://www.mydomain.com

In other words, remove the index.html part of the code...

Something like this maybe:

  RewriteRule ^$ index.html [NC]

Thanks

UPDATE:

When you type www.domain.com into the browser, offcourse index.html is opened.
But when you click on "home" on the menu on my website, the entire full url is displayed, which I want to avoid. So when hitting "home" www.domain.com/index.html is shown... But not when entering www.domain.com in the adress bar, then only that will show, but index.html comes up anyways.

So yes, I need this:

www.domain.com/

Not this:

www.domain.com/index.html

Thanks

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

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

发布评论

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

评论(2

绿光 2024-09-23 16:50:22

将 /index.html 的请求重定向到 /

RewriteRule ^index.html$ http://www.mydomain.com/ [R=301,L]

To redirect requests for /index.html to /

RewriteRule ^index.html$ http://www.mydomain.com/ [R=301,L]
ι不睡觉的鱼゛ 2024-09-23 16:50:22

我认为它是这样的:

RewriteRule ^index.html$ / [NC]

将“index.html”替换为“/”,而不是“”替换为“index.html”

I think its like this:

RewriteRule ^index.html$ / [NC]

Replace "index.html" with "/", not "" with "index.html"

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