替换 htaccess 中的主机

发布于 2024-09-15 06:56:08 字数 519 浏览 1 评论 0原文

我正在创建一个位于我的网络服务器上的 /shop/ 的网站。它有一个单独的域。

现在,我想更改传入的每个请求。

http://techinf.de/shop/ 应成为 http://holzwerkstatt-osel.de/ 并且 http://www.techinf.de/shop/ 应变为 http://www.holzwerkstatt-osel.de/

实际请求,如product.php?id=2必须相同。

I am creating a website which is located in /shop/ on my webserver. It has a seperate domain.

Now, I want to change every request that comes in.

http://techinf.de/shop/ shall become http://holzwerkstatt-osel.de/ and
http://www.techinf.de/shop/ shall become http://www.holzwerkstatt-osel.de/

the actual request, like product.php?id=2 must be the same.

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

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

发布评论

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

评论(1

人海汹涌 2024-09-22 06:56:10

由于您想要保留 www (或缺少该内容),因此您可能需要使用 mod_rewrite 来实现此目的。以下内容应该有效:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?technif\.de$
RewriteRule ^shop/(.*)$ http://%1holzwerkstatt-osel.de/$1 [R=301,L]

编辑:如果您不关心整个 www 内容,只需在 technif.de 上使用 mod_alias 应该可以工作:

Redirect permanent /shop http://holzwerkstatt-osel.de

这将获取 /shop 之后的所有内容并将其附加到重定向 URL,然后进行重定向。因此 /shop/product.php?id=2 变为 http://holzwerkstatt-osel.de/product.php?id=2 等。

Since you want to persist the www (or lackthereof), you likely do need to use mod_rewrite for this. The following should work:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?technif\.de$
RewriteRule ^shop/(.*)$ http://%1holzwerkstatt-osel.de/$1 [R=301,L]

Edit: If you don't care about the whole www thing, just using mod_alias on technif.de should work:

Redirect permanent /shop http://holzwerkstatt-osel.de

This takes everything after /shop and appends it to the redirection URL, then redirects. So /shop/product.php?id=2 becomes http://holzwerkstatt-osel.de/product.php?id=2, etc.

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