我似乎无法弄清楚如何 301 将旧 URL 重定向https://www.mydomain.com/old_url/
到https://www.mydomain.com/new_url/
我目前在我的 htaccess 中有以下内容(注意与此问题相关的第二条规则):
RewriteEngine On
# SSL redirect
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule ^(.*) https://www.mydomain.com$1 [R=301,nc]
RewriteCond %{THE_REQUEST} ^GET\ /old_url/
RewriteRule ^/old_url$ https://www.mydomain.com/new_url [R=301,nc]
# If the root has a querystring with at least 1 character
RewriteCond %{QUERY_STRING} ^.+
RewriteRule ^/?$ https://www.mydomain.com/new_home_page [R=301,nc]
如果这有所作为,我也在使用 Django。任何帮助是极大的赞赏。