将 /index.php?/bitcoin 重定向到 /bitcoin - Codeigniter 301 重定向问题

Redirect /index.php?/bitcoin to /bitcoin - Codeigniter 301 redirect issue

我一直在努力处理一些 htaccess 重定向。我只是花了一些时间阅读和搜索堆栈,但无法获得适合我的场景的答案。

我正在将旧客户网站的 301 重定向到新网站。

这是旧页面 URL

https://digitalcoinprice.com/index.php?/first-bitcoin

https://digitalcoinprice.com/first-bitcoin

我有多个页面要做,这里有几个例子:

index.php?/msd
index.php?/bitcoin
index.php?/ripple

其中所有 link 到不同的新页面。

这是我尝试过的:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ / [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]

我被正确重定向,但是 URL 保持这样的查询字符串:

https://digitalcoinprice.com/?/first-bitcoin

没用(还有查询字符串)

谢谢!

在您的 htaccess 顶部,放置以下规则:

RewriteEngine on


RewriteCond %{THE_REQUEST} /index\.php\?/(.+)\sHTTP  [NC]
RewriteRule ^.*$ https://digitalcoinprice.com/%1? [L,R]

这将重定向 https://digitalcoinprice.com/index.php?/any-valuehttps://digitalcoinprice.com/any-value.