【问题标题】:Rewrite URL using htaccess php使用 htaccess php 重写 URL
【发布时间】:2013-04-12 07:27:56
【问题描述】:

我想在我的项目中重写 url。

例如:

http://www.example.com/dashboard/test/http://dashboard.example.com/index.php

我也想这样做:

http://www.example.com/dashboard/test2/http://dashboard.example.com/index.php

谁能告诉我重写网址的想法?

【问题讨论】:

  • 当你说“rewrite from A to B”时,这意味着当你在浏览器的 URL 地址栏中输入 A 时,你就会得到服务B 的内容,但 A 仍保留在您的地址栏中。这就是你想要的吗?
  • Can anyone tell me the idea to rewrite the url. 是的。肯定有人能做到这一点。 尝试过什么?
  • 你在 apache 上。对吗?
  • 是的,@JonLin 是对的。如果你能详细解释你的问题,我可以完全帮助你。

标签: php .htaccess url-rewriting


【解决方案1】:

首先,您在根目录中创建一个 .htaccess 文件。 比,只需将重定向命令放入其中。 如何编写 .htaccess 以及如何创建重写规则在这里解释:http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/

你需要这样的东西:

RewriteRule ^(.*)$ http://dashboard.example.com/$1 [L,QSA]

【讨论】:

    【解决方案2】:

    试试这个

     Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^test.*$  http://dashboard.example.com/index.php [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 2022-01-08
      • 2012-04-29
      • 2012-08-25
      • 2012-06-10
      • 1970-01-01
      相关资源
      最近更新 更多