简体   繁体   English

.htacces从example.com/abc重定向到https://www.example.com/abc

[英].htacces redirect from example.com/abc to https://www.example.com/abc

htaccess: htaccess:

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]  

Above code I'm using in my .htaccess and Now I want to redirect when someone type example.com/abc to https://www.example.com/abc . 以上我在.htaccess使用的代码,现在当有人将example.com/abc键入https://www.example.com/abc时,我想重定向。

By using the above code when I goto example.com/abc its showing 404 error. 通过使用上面的代码,当我转到example.com/abc它显示404错误。

So please someone help me to solve this. 所以请有人帮我解决这个问题。 Answers are appreciated. 答案表示赞赏。

You can use: 您可以使用:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以将 example.com/index.php?page=abc 重定向到 example.com/abc? - Is it possible to redirect the example.com/index.php?page=abc to example.com/abc? 在htacess中从https://example.com重定向到https://www.example.com - Redirecting from https://example.com to https://www.example.com in htacess Avoid multiple page redirects http://example.com > https://example.com -> https://www.example.com - Avoid multiple page redirects http://example.com > https://example.com -> https://www.example.com 使用htaccess将http://www.example.com/重定向到https://www.example.com/ - redirect http://www.example.com/ to https://www.example.com/ with htaccess 为什么“www.example.com”与“example.com”不一样? - Why is “www.example.com” not the same as “example.com”? example.com和www.example.com被视为不同的会话 - example.com and www.example.com are treated as different sessions 在example.com中使用setcookie(),在www.example.com中找不到cookie - setcookie() in example.com, cookie not found in www.example.com 什么是将www.example.com重定向到example.com的最佳方法 - What is Best way to redirect www.example.com to example.com 如何从Facebook通知重定向到:https://apps.facebook.com/appname/而不是:www.example.com? - How to redirect from Facebook notification not to: https://apps.facebook.com/appname/ but to: www.example.com? WordPress mod_rewrite规则。 停止从example.com重定向到www.example.com - Wordpress mod_rewrite rule. Stop redirecting from example.com to www.example.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM