簡體   English   中英

將非.www規則重寫為.htacces magento上的https到www.https

[英]rewrite rule for non.www to https to www.https on .htacces magento

我想重定向https://example.comhttps://www.example.com為我的網站。 您能幫我把它放在.htaccess文件中的代碼嗎? 該網站位於magento。

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

說明:如果請求的主機不是以www。開頭,請將其重定向為以www開頭

來源|參考: http : //codingbasics.net/magento-htaccess-file-optimized-speed-security-seo/

上面的鏈接有一個默認的Magento htaccess文件,該文件已針對速度和SEO進行了優化,並且具有用於將非www重寫為www的代碼,但是沒有用於將HTTPS / SSL非www重寫為www的代碼。 因此,我從上面的鏈接/站點中獲取了htaccess代碼部分,並對下面的代碼進行了其他編輯,以將HTTPS / SSL非www重寫為www。

##### Search Engine redirects and rewrites for SEO purposes #####

<IfModule mod_rewrite.c>
    # Rewrite|Redirect http to https|SSL & non-www to www
    RewriteCond %{HTTPS} !=on
    RewriteCond %{SERVER_PORT} ^80
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
    RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L]

    ##### Redirect away from /index.php and /home   
    ##### Warning: This index.php rewrite will prevent Magento 
    ##### Connect from working. Simply comment out the  
    ##### following two lines of code when using Connect.
    ##### Please note - https://www. if not using www simply use https://

    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ https://www.yourdomain.com/$1 [R=301,L]

    ##### Please note - https://www. if not using www simply use https://
    redirect 301 /home https://www.yourdomain.com

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM