【问题标题】:Redirecting index.php?p= to product.php?id= using htaccess使用 htaccess 将 index.php?p= 重定向到 product.php?id=
【发布时间】:2021-09-27 13:56:59
【问题描述】:

我知道这很容易解决,我只是到处寻找并尝试了一切都没有成功,所以我不得不在这里问;

如何使用 htaccess 将 index.php?p=(number) 或 /?p= 301 重定向到 product.php?id=(number)。

我认为这可能有效,但它没有

RewriteEngine on
RewriteBase /
RewriteRule ^(index.php|?)p\=([0-9]+)$ product.php?id=$2 [R=301]

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting friendly-url


    【解决方案1】:

    使用您显示的示例/尝试,请尝试遵循 htaccess 规则。确保在测试 URL 之前清除浏览器缓存。

    RewriteEngine ON
    RewriteBase /
    RewriteCond %{THE_REQUEST} \s/index\.php\?p=(\d+)\s [NC]
    RewriteRule ^ product.php?id=%1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-11
      相关资源
      最近更新 更多