我想将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