【问题标题】:Using .htaccess, how to display another URL's content as if it were the current URL使用 .htaccess,如何显示另一个 URL 内容,就好像它是当前 URL
【发布时间】:2019-11-20 17:19:50
【问题描述】:

我想向用户显示另一个 URL 的内容,当他转到我的 URL 时,但不完全更改 URL。例子: 当他去http://example.com时我想让他看到http://example.com/another/url的内容 但我希望他相信(在浏览器中查看)他给定的 URL。 如何使用.htaccess 做到这一点?有什么建议吗?

【问题讨论】:

    标签: .htaccess redirect mod-rewrite url-rewriting


    【解决方案1】:

    试试这个:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/(.*)$ http://example.com/another/url/$1 [R=301,L]
    

    【讨论】:

      【解决方案2】:

      您可以在站点根目录 .htaccess 中使用此规则:

      RewriteEngine On
      
      RewriteRule ^/?$ /another/url [L]
      

      当您在浏览器中请求 http://example.com/ 时,这将加载 /another/url,但不会更改浏览器 URL。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-05
        • 2020-04-01
        • 1970-01-01
        • 2013-03-27
        • 2017-10-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多