【问题标题】:htaccess rewrite one url on subdomainhtaccess 在子域上重写一个 url
【发布时间】:2019-04-25 06:09:40
【问题描述】:

如何在 .htaccess 中创建子域

example.domain.com/gallery/index.html 进入example.domain.com/gallery/

【问题讨论】:

  • 通过为该请求 URL 实施重写规则。你会在网上找到无数的例子。
  • 做了很多例子,我得到了 500 错误
  • 好的,那么请展示其中的一两个示例,并将您收到的条目添加到您的 http 服务器错误日志文件中。
  • RewriteRule ^gallery/([A-Za-z]+)/$ /gallery/index/$1.html [L]
  • 嗯,直接的方法类似于RewriteRule ^/?gallery/index\.html$ /gallery/ [END]。但这可能会导致无休止的重写循环,具体取决于我们不知道的设置。

标签: .htaccess url mod-rewrite path


【解决方案1】:

不确定您对问题的最后评论要说什么。我发布的规则恰好重写了一个 URL。但也许你正在寻找相反的重定向,我刚刚意识到,所以:

RewriteEngine on
RewriteRule ^/?gallery/index\.html$ /gallery/ [R=301]
RewriteRule /?gallery/?$ /gallery/index.html [END]

这会重定向请求 /gallery/indx.html 的客户端,但在请求 /gallery 时仍会传递本地文件 /gallery/index.html

【讨论】:

    猜你喜欢
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 2012-04-03
    相关资源
    最近更新 更多