mod_rewrite 不带变量的虚拟目录

发布于 2024-12-11 06:10:16 字数 333 浏览 4 评论 0原文

我还没有为此想出解决方案。我想要有多个虚拟目录,但无法找到如何在不使用 PHP 或某种变量的情况下做到这一点。比如我想要:

mysite.com/restaurant/ to point to mysite.com/restaurant.php

mysite.com/restaurant/menu/ to point to mysite.com/restaurant-menu.php
mysite.com/restaurant/location/ to point to mysite.com/restaurant-location.php

等等,没有动态内容;我有所有的文件。

I haven't come up with a solution for this. I want to have multiple virtual directories but cant find how to do it without using PHP or some sort of variables. For example I want:

mysite.com/restaurant/ to point to mysite.com/restaurant.php

mysite.com/restaurant/menu/ to point to mysite.com/restaurant-menu.php
mysite.com/restaurant/location/ to point to mysite.com/restaurant-location.php

And so on, there is no dynamic content; I have all the files.

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

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

发布评论

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

评论(1

若水般的淡然安静女子 2024-12-18 06:10:16

您可以使用 mod_rewrite 来做到这一点!

RewriteEngine on
RewriteRule ^restaurant/?$  restaurant.php [L]
RewriteRule ^restaurant/menu/?$  restaurant-menu.php [L]
RewriteRule ^restaurant/location/?$  restaurant-location.php [L]

you can use mod_rewrite to do that!

RewriteEngine on
RewriteRule ^restaurant/?$  restaurant.php [L]
RewriteRule ^restaurant/menu/?$  restaurant-menu.php [L]
RewriteRule ^restaurant/location/?$  restaurant-location.php [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文