【问题标题】:mod_rewrite rewrite url using .htaccess phpmod_rewrite 使用 .htaccess php 重写 url
【发布时间】:2013-04-10 05:39:53
【问题描述】:

我是 htaccess 规则的新手。

我想要一个将两个网址视为一个的规则。

这两个应该被视为相同的 URL。我只想将 sites/client1 添加到实际上什么都不做的 URL。每个 URL 请求都应该包含 sites/client1/。

对于下一个请求,如

  • multisite2/index.php?id_product=1&controller=product
  • multisite2/sites/client1/index.php?id_product=1&controller=product

感谢您的帮助。

【问题讨论】:

标签: php .htaccess


【解决方案1】:

试试这个:

RewriteRule index.php?(.*) sites/client1/index.php?$1

在此处发布之前,请先搜索一下。此问题的一些可能重复项如下:

.htaccess URL rewrite with one and two query string vars

htaccess url rewrite to .php

【讨论】:

  • 您好 mtndesign,感谢您的帮助。它现在实际上重定向到sites/client1/index.php。我不想要这个我只想在 URL 中显示它。但在内部它应该保持在domain.com/folder/multisite/index.php 再次感谢
  • sites/client1/ 只是虚拟参数
  • 您的意思是您不想重定向用户,您只想将sites/client1/index.php 视为index.php?然后你应该更新你的问题。作为解决方案,您应该使用mod_proxy。检查 apache 文档并查看以下问题:q1q2。如果您需要任何代码,我可以提供给您。
  • 哦,我忘记了mod_proxy 的链接。 Here 是。
  • 您看过我提供给您的问题1了吗?这就是我要在这里发布的代码。
【解决方案2】:

这会将 /sites/client1/ 中的所有请求发送到 /

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^sites/client1/(.*)$ $1 [L,QSA]
</IfModule>

【讨论】:

  • 嗨沉默男孩,感谢您的帮助。同样的问题,它现在实际上是重定向到 / 。简单地说,/sites/client1/ 应该保留在 URL 中,但在内部它应该调用 domain.com/folder/multisite/index.php
  • sites/client1/ 只是虚拟参数
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-22
  • 1970-01-01
  • 2021-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多