0
我正在嘗試將我網站上的所有以下網址重定向到新版本。這裏是我們的目標:.htaccess使用GET變量的通配符重定向
BEFORE(注意,沒有 '.PHP ')
https://example.com/view?username=asdf1234
重定向到(有' .PHP' 和內部的 '工具' 文件夾)
https://example.com/tool/view.php?username=asdf1234
我試了幾個例子,但無法弄清楚。這是我最好的猜測
RewriteEngine On
RewriteRule ^/view\?username=(.+) /tool/view.php?%1 [L,R=301]
添加
RewriteEngine On
RedirectMatch ^/view(.*)$ https://example.com/tool/view.php$1
成功重定向但它是一個302重定向。當我添加[L,R = 301]時,它給出了一個500錯誤。
我剛試過,當我訪問https://example.com/view?username=test沒有重定向 – StackOverflower
你有其他重寫規則優先嗎?也許更高的地方 –
我把它移到我的.htaccess文件的頂部,沒有什麼是重定向。 – StackOverflower