在我的.htaccess中重定向到https不起作用

时间:2019-04-02 11:07:25

标签: .htaccess mod-rewrite

我有.htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteRule cache/ - [F]
Options -Indexes

RewriteCond %{HTTP_HOST} ^www.domains.eu [NC]
RewriteRule ^(.*)$ https://domains.eu/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z0-9\-\_\/]*)$ index.php?p=$1


# Blokada hotlinking czyli kradzieży obrazków
RewriteCond %{HTTP_REFERER} !^https://(.+\.)?domains.pl/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
#RewriteRule .*\.(jpe?g|jpg|gif|bmp|png|jpeg)$ - [F]

#AuthType Basic
#AuthName "Password Protected Area"
#AuthUserFile /home/webplay/domains/domains.eu/public_html/.htpasswd
#Require valid-user



# Prevent viewing of htaccess file.
<Files .htaccess>
    order allow,deny
    deny from all
</Files>
RedirectMatch 403 ^.*/apps/(.*).php(.*)$

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl|map)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

我需要以下重定向:

  • 从http:// domains .pl,http://www.domains .pl,https://www.domains .pl,https:// domains .pl重定向到https:// domains。欧盟

  • 从https://www.domains .eu,http://www.domains .pl,http:// domains .eu重定向到https:// domains .eu

我可以从我的.htaccess中寻求帮助吗?

1 个答案:

答案 0 :(得分:1)

请您添加以下代码并对其进行测试?

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://domains.eu/$1 [L,R=301]
相关问题