我想通过htaccess的www将所有非www和非https网址重定向到https。
我通过谷歌搜索尝试了许多代码,但无法解决我的问题
我正在分享我现有的htaccess代码
php_value post_max_size 2000M
php_value upload_max_filesize 2000M
php_value memory_limit 100000M
php_value max_execution_time 1000000
#### Rule for Error Page - 404 ####
ErrorDocument 404 http://gpe360.com/index_home.php
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<Files index.html>
SetOutputFilter DEFLATE
</Files>
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
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>
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip
Options +ExecCGI +FollowSymLinks
RewriteEngine On
RewriteRule ^villas/rent.php$ rent.php?$1 [QSA]
RewriteRule ^house/homes.php$ homes.php?$1 [QSA]
RewriteRule ^apartment/apartment.php$ apartment.php?$1 [QSA]
RewriteRule ^apartmentland/land.php$ land.php?$1 [QSA]
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ property_details.php?id=$2
RewriteRule ^region--(.*)--(.*)\.html$ region_details.php?rid=$1
RewriteRule ^cyprus_details\.html$ cyprus_details.php
RewriteRule ^agent-(.*)-(.*)\.html$ view_public_profile.php?uid=$1
RewriteRule ^News-(.*)-(.*)\.html$ news_detail.php?id=$1
RewriteRule ^Resource-(.*)-(.*)\.html$ useful_resource_details.php?rid=$1
RewriteRule ^independent_account.php(.*) /makepayment/account.php?ac_type=2 [R=301,L]
RewriteRule ^professional_account.php(.*) /makepayment/account.php?ac_type=3 [R=301,L]
RewriteCond %{HTTP_HOST} ^gpe360\.com$ [NC]
RewriteRule ^(.*)$ http://www.gpe360.com/$1 [R=301,L]
ErrorDocument 404 http://www.gpe360.com
#Options -Idexes
实时网址是www.gpe360.com。
答案 0 :(得分:0)
在RewriteEngine on
RewriteCond {HTTPS} on
RewriteCond {HTTP_HOST} !^www
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]
删除您之前在代码中进行测试的尝试。