mod_rewrite:不同域的不同规则,相同的 www-root

发布于 2024-09-04 21:25:02 字数 309 浏览 1 评论 0原文

我有 8 个域名指向同一个 www-root。如果访问主域,您将指向index.php,从那里开始,URL 类似于:index.php?p=contact 等。但是,如果您访问其他 7 个域之一,则指向不同的单位,您最初指向:index_local.php,从那里开始它像:index_local.php?p=contact 等。

正如您可能会看到这些 URL 非常丑陋,我可以在这种情况下使用 mod_rewrite 来实现它这样index.php 和index_local.php 永远不会出现在URL 中?有没有比我现在在同一个 www 根目录中使用多个域指向用户的方式更好的方法?

I have 8 domainnames that point to the same www-root. If the main domain is accessed, you are pointed to index.php, and from there on, the URL's are like: index.php?p=contact etc. If, however, you access one of the other 7 domains, that point to different units, you are initially pointed to: index_local.php, and from there on it goes like: index_local.php?p=contact etc.

As you may see these URL's are very ugly, can I use mod_rewrite in this scenario to make it so that index.php AND index_local.php never show up in URL? Is there any better way to do this than the way I'm pointing the user now with multiple domains in the same www-root?

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

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

发布评论

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

评论(1

孤千羽 2024-09-11 21:25:02

像这样的东西应该有助于隐藏索引* URL:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond    %{HTTP_HOST}    ^domainname1.com
RewriteRule    ^/(.*)$    index.php?p=$1 [L]

RewriteRule    ^/(.*)$    index_local.php?p=$1 [L]
</IfModule>

如果您愿意更改一些代码,还有其他方法可以干净地做到这一点,但这应该适用于您拥有的代码。

Something like this should help hide the index* URLs:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond    %{HTTP_HOST}    ^domainname1.com
RewriteRule    ^/(.*)$    index.php?p=$1 [L]

RewriteRule    ^/(.*)$    index_local.php?p=$1 [L]
</IfModule>

There are other ways to do this cleanly, if your willing to change some code, but this should work with the code you have.

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