【问题标题】:.htaccess help for redirect.htaccess 帮助重定向
【发布时间】:2016-04-07 19:41:02
【问题描述】:

在尝试重定向域时需要一些帮助:

https://www.example.com/blog/page/10/?page_id=%2Ffeed%2Fatom%2F 到 /blog/

我认为最好的方法是在 /page 之后重定向任何内容

下面的代码是我的想法,但我知道不正确:

RewriteEngine on RewriteCond %{THE_REQUEST} /blog/page/[0-255]* [NC] RewriteRule ^ /blog/? [NC,R=301,L]

有什么建议吗?

【问题讨论】:

标签: linux .htaccess


【解决方案1】:

在尝试重定向域时需要一些帮助:

如果您尝试重定向域,请使用类似

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [OR]
RewriteRule ^(.*)$       "http://www\.exampe2\.com\/blog/" [R=301,L]

如果要将请求附加到 URL,请使用 $1

如果您要重写 /blog/ 的路径并希望保留查询字符串,请使用 [QSA] 标志,即。

RewriteRule /blog/(.*) /blog/ [R=301,QSA,L]

这将确保您保留查询字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多