【问题标题】:.htaccess - Show contents of original URL under a different URL.htaccess - 在不同的 URL 下显示原始 URL 的内容
【发布时间】:2018-01-15 12:22:19
【问题描述】:

我希望我的原始 URL http://example.com/ 的内容在访问时显示在此 URL 下:http://example.com/seller/nokianokia 是动态的。我怎样才能做到这一点?

url 必须在所有页面中保持不变,例如,如果我导航到页面 http://example.com/seller/nokia/about.php,那么它将映射到 http://example.com/about.php

我没有使用任何框架。

我是 htaccess 的新手,所以我真的希望有人可以帮助我。我很确定这不是 StackOverflow 中任何现有问题的重复。

【问题讨论】:

  • 你在使用任何框架吗?
  • @jok3r 不,我没有使用任何框架。
  • 我认为您需要在 .htaccess 中重写一些规则。试试这个stackoverflow.com/questions/14895980/…
  • 试试看,让我知道 :)
  • 抱歉,这对我不起作用。我已经使用 XAMPP 进行了测试

标签: .htaccess


【解决方案1】:

将此添加到您的 .htaccess 以重定向所有 php 和 html 页面以从主目录获取。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/seller/(?:.*)/(.*\.(?:html|php))$ /$1 [R,L]
</IfModule>

这会将/seller/nokia/about.php 重定向到/about.php

或者,您仍然可以将/seller/nokia/about.php 显示为网址并从/about.php 获取它。为此,只需将 R 标志更改为 QSA 标志。

【讨论】:

    猜你喜欢
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    • 2012-02-11
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多