似乎无法 mod_rewrite 实际存在的路径

发布于 2024-12-25 02:44:10 字数 367 浏览 0 评论 0原文

我想重写如下:

RewriteRule ^abc([.]*)$ /abc.py$1

如果 abc 不是目录,则此方法有效。即 http://eg.com/abc 将根据需要显示 abc.py 页面,但是如果我 mkdir abc 在根目录中,然后 http://eg.com/abc 将实际显示内容abc 目录的。

如果 /abc 是目录,如何使重写显示文件 /abc.py

I want to rewrite as follows:

RewriteRule ^abc([.]*)$ /abc.py$1

This works if abc is not a directory. I.e. http://eg.com/abc will show the abc.py page as desired, however if I mkdir abc in the root then http://eg.com/abc will actually show the contents of the abc directory.

How do I make the rewrite show the file /abc.py if /abc is a directory?

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

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

发布评论

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

评论(1

梅倚清风 2025-01-01 02:44:10

也许可以尝试这个:

RewriteRule ^abc(.*)$ /abc.py$1 [R]

对我来说它工作得很好。
使用[R]您将更容易看到结果。
您还可以尝试将 RewriteBase / 添加到 .htaccess 文件中 RewriteRule 之前。

当我使用 [.] 而不是仅使用 .我根本无法使重写工作,所以我无法真正准确地重现您的问题,但希望这有任何帮助。

Maybe try this instead:

RewriteRule ^abc(.*)$ /abc.py$1 [R]

For me it works just fine.
With [R] you will see the result more easily.
You can also try adding RewriteBase / to the .htaccess file before the RewriteRule.

When I used [.] instead of just . I couldn't make the Rewrite work at all, so I wasn't really able to reproduce your issue exactly, but hope this is of any help.

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