我想將https://example.com重定向到https://www.example.com爲我的網站。你可以幫我把代碼放在.htaccess文件中。該網站在magento。對non.www的https重寫規則https。www.https on .htacces magento
0
A
回答
0
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
解釋:如果請求的主機不以www開始,重定向它開始以www
+0
Thankyou,但我需要的代碼爲HTTPS ..沒有www重定向到與www –
+0
這是https的代碼? – Garytje
0
來源|引用:http://codingbasics.net/magento-htaccess-file-optimized-speed-security-seo/
上面的鏈接有具有默認的Magento htaccess文件已針對速度和搜索引擎優化進行了優化,並且具有將非www重寫爲www的代碼,但是沒有用於將www重寫HTTPS/SSL非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>
相關問題
- 1. htaccess wordpress https重寫規則
- 2. 重寫規則https:// www到https:// IIS7
- 3. 重寫規則對HTTP和HTTPS
- 4. HTTPS重寫規則重定向過多
- 5. wordpress htaccess重寫規則https到http
- 6. 需要爲IIS重寫的規則https
- 7. HTTPS請求忽略重寫規則
- 8. Htacces重寫爲magento http到https爲一個域的多文化
- 9. htaccess規則重寫.htacces
- 10. .htacces重寫規則問題
- 11. .htacces - 重寫規則與規則2
- 12. https到Http規則重寫Azure
- 13. 重定向規則到https
- 14. 如何使用重寫規則重定向到https,但相對?
- 15. .htacces重寫規則重定向
- 16. .htacces重寫規則不起作用
- 17. .htacces在子目錄中隱藏Magento商店的重寫規則
- 18. 對特定網址啓用https使用重寫規則
- 19. HTACCES國防部重寫,堆放規則
- 20. Ruby on Rails - .htacces重寫規則以更改圖像路徑
- 21. IIS爲HTTP重寫規則到https與規範的主機
- 22. 徐網址 - htacces重寫規則
- 23. HTACCES重寫規則不帶參數
- 24. htaccess - 重寫規則SSL重定向到https:// www
- 25. IIS重寫規則在web.config中重定向HTTPS請求HTTP
- 26. .htaccess將HTTPS強制添加到現有的重寫規則
- 27. htaccess的重寫規則到https不起作用與其他規則組合
- 28. 阿帕奇重寫規則下工作不HTTP下的https
- 29. 需要什麼重寫規則停止在子域上的https
- 30. 的Symfony2 +的Apache2:重寫規則應該涵蓋HTTPS
[通用htaccess的重定向到WWW非www]的可能的複製(http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www) –
我投票關閉這個問題作爲脫離主題,因爲堆棧溢出是[編程相關](http://stackoverflow.com/help/on-topic)問答網站。你的問題不是關於編程。也許你應該在http://magento.stackexchange.com上發佈它呢? – Enigmativity