使用htaccess将多个域重定向到具有或不带有https的www的一个域

时间:2017-07-16 12:42:23

标签: apache .htaccess

大家好,这段代码不能正常工作

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

################## Force HTTPS & WWW ################
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
################# Contact ############################
RewriteCond %{HTTP_HOST} ^contact-services.net [OR]
RewriteCond %{HTTP_HOST} ^contactmadinaty.com [OR]
RewriteCond %{HTTP_HOST} ^contactmadinaty.net [OR]
RewriteCond %{HTTP_HOST} ^madinaty.city [OR]
RewriteCond %{HTTP_HOST} ^madinatyrealestate.com [OR]
RewriteCond %{HTTP_HOST} ^madinatyrealestate.net [OR]
RewriteCond %{HTTP_HOST} ^realestate-madinaty.com [OR]
RewriteCond %{HTTP_HOST} ^realestatemadinaty.com [OR]
RewriteCond %{HTTP_HOST} ^realestatemadinaty.net
RewriteRule ^(.*)$ https://www.contact-madinaty.com/$1 [R=permanent,L]
######################################################

以上代码用于将非www重定向到使用https而不是重定向域的www

1 个答案:

答案 0 :(得分:0)

以下内容有帮助吗?这对我来说很好用

from django.contrib.auth.views import password_reset

urlpatterns = patterns('',
     (r'^/accounts/password/reset/$', password_reset,{'template_name': 'my_templates/password_reset.html'}, name='password_reset_done'),
     ...
)