【问题标题】:.htaccess Redirect 301 with ? (without variables).htaccess 重定向 301 与? (无变量)
【发布时间】:2020-07-11 03:57:46
【问题描述】:

有些网址带有 ?.

/shop/index.php?route=affiliate/register

/shop/?route=affiliate/register

需要将这些 url 重定向到:

/another-page/

(假设所有 url 都以主目录开头。例如:www.homepage.com/shop?route=affiliate/register)

我已经尝试过简单的 apache Redirect 301 和 rewrite。

【问题讨论】:

    标签: regex .htaccess redirect


    【解决方案1】:

    您可以将此规则用作站点根目录 .htaccess 中的首要规则:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} /shop/(?:index\.php)?\?route=[^\s&]+ [NC]
    RewriteRule ^ /another-page/? [R=301,L,NE]
    

    【讨论】:

    • 感谢您分享好命令,先生,您能否让我知道如何在我的本地系统中进行测试?是否有 curl 命令或在浏览器中?先生,如果您能在这里指导,将不胜感激
    • 我使用命令行 curl 进行设置。我有一个使用 LAMP/MAMP 堆栈运行的本地 Apache+php。
    猜你喜欢
    • 2019-02-23
    • 1970-01-01
    • 1970-01-01
    • 2021-01-06
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 2013-09-19
    相关资源
    最近更新 更多