【问题标题】:.htaccess rewrite rule with get params.htaccess 使用获取参数重写规则
【发布时间】:2016-07-14 17:21:51
【问题描述】:

我需要能够重写http://example.com/staging/details/?postid=23,使其变为http://example.com/staging/grandhotelterduin

我不确定 .htaccess 规则应该如何?

我想出了这样的东西

Options +FollowSymLinks  
RewriteEngine On 

RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC]

我不确定我这样做是否正确,请您帮忙

我希望 http://example.com/staging/grandhotelterduin/ 被重定向到 http://example.com/staging/details/?postid=23 但浏览器中显示的 url 是 `http://example.com/staging/grandhotelterduin

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    使用这个:

    RewriteEngine On
    RewriteRule ^grandhotelterduin$ /staging/details/?postid=23 [L]
    

    它会给你以下网址:

    http://sheetz.nl/grandhotelterduin

    编辑:

    RewriteCond %{THE_REQUEST} /staging/details/?postid=([0-9]+)  [NC]
    RewriteRule ^ /staging/grandhotelterduin [L,R]
    

    【讨论】:

    • 能否请您再检查一遍规则
    • 你可以试试我的编辑,但是当我测试我之前的规则时,它起作用了。确保该规则位于您的 .htaccess 顶部并且您的缓存已被清除。
    猜你喜欢
    • 2016-12-14
    • 1970-01-01
    • 1970-01-01
    • 2018-02-03
    • 2013-12-26
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多