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