[英]Htaccess only home page https://a.com to https://www.a.com redirect
My htaccess (codeigniter) 我的htaccess(codeigniter)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
if visitor open main page https://example.com need to redirect -> https://www.example.com 如果访问者打开主页https://example.com需要重定向-> https://www.example.com
But i have already redirect for my links. 但是我已经重定向了我的链接。 I need to do together current codes.
我需要一起做当前的代码。
How can i do? 我能怎么做?
Edit 1: 编辑1:
this is i want:
这是我想要的:
https://example.com -> https://www.example.com , https://example.com/somepage -> https://example.com/somepage (No change) , https://www.example.com/otherpage.html -> https://example.com/otherpage.html (No use www redirected)
https://example.com - > https://www.example.com , https://example.com/somepage - > https://example.com/somepage (无变化), https://开头WWW。 example.com/otherpage.html- > https://example.com/otherpage.html (不使用www重定向)
Only the main page will use www.
只有主页将使用www。 tag
标签
All other page not use www.
所有其他页面均不使用www。
Try this 尝试这个
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
You should use RedirectMatch
to achive your goal. 您应该使用
RedirectMatch
实现目标。
Try this: 尝试这个:
RedirectMatch 301 https://example.com https://www.example.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.