Apache htaccess删除www重定向到ssl但url错误
我用php创建了一个mvc框架。我唯一的工作主文件是index.php 通常我从http重定向到https。我也会删除www域,但是当我使用www进入时,如果我的URL是Apache htaccess删除www重定向到ssl但url错误,apache,.htaccess,redirect,mod-rewrite,url-rewriting,Apache,.htaccess,Redirect,Mod Rewrite,Url Rewriting,我用php创建了一个mvc框架。我唯一的工作主文件是index.php 通常我从http重定向到https。我也会删除www域,但是当我使用www进入时,如果我的URL是 domain.com/admin/products/edit/1, htaccess就是这样做的 domain.com/index.php/products/edit/1 我怎样才能解决这个问题 多谢各位 RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d Rewri
domain.com/admin/products/edit/1,
htaccess就是这样做的
domain.com/index.php/products/edit/1
我怎样才能解决这个问题
多谢各位
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
您应该有这样的规则,始终保持https重定向规则只放在第一位。请在测试URL之前清除浏览器缓存(其余规则来自OP的试用规则+我在这里也更改了匹配主机名的正则表达式)
非常感谢你。为我工作
RewriteEngine ON
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^(?:www\.)(example\.com) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ index.php [L]