问题
I am looking for an Apache redirect where the source URL has a question mark in it.
Redirect permanent /course/view.php?id=68 http://exmaple.com/page.php
I've tried escaping the question mark, but that doesn't work. I've read a couple pages on the web about using Rewrite conditions, however it didn't quite make sense to me, or it was a little bit different than what I wanted to accomplish.
回答1:
Try adding the following to the .htaccess
file in the root directory of your site.
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /course/view\.php\?id=68 [NC]
RewriteRule ^ http://exmaple.com/page.php [L,R=301]
来源:https://stackoverflow.com/questions/9182585/apache-redirect-permanent-for-url-with-data-in-string-question-mark