简体   繁体   English

多个htaccess重写条件/角度路由html5模式

[英]multiple htaccess rewrite Conditions / angular routes html5 mode

i have a angular project with routes in html5 mode. 我在html5模式下有一个带有路线的角度项目。 I set up a htaccess file, that is possible to insert a domain manually or refresh the page. 我设置了一个htaccess文件,可以手动插入域或刷新页面。

here the htaccess code with works fine, based on this Still getting 'Not Found' when manually refreshing with angular.js route 这里的htaccess代码可以正常工作,基于此当使用angular.js路由手动刷新时仍然得到``未找到''

    RewriteEngine On

 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]

 RewriteRule ^ myFolder/myFile.php [L]

but now i want also to redirect the url to https width www, for example: 但现在我也想将URL重定向到https宽度www,例如:

http://example.com should become https://www.example.com http://example.com应该变成https://www.example.com

there for i used this: 在那里我用这个:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

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

But when i try to combine this scripts i always get error! 但是,当我尝试结合使用这些脚本时,我总是会出错!

Thanks! 谢谢!

I'm not sure how you're trying to combine the code, but you should be able to do it this way. 我不确定您如何尝试组合代码,但是您应该可以这样做。 Replace example.com with your domain. 您的域替换example.com

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTPS} !^on [OR]
 RewriteCond %{HTTP_HOST} ^example\.com [NC]
 RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]

 RewriteRule ^ myFolder/myFile.php [L]

Clear your browser cache before trying the new rules. 在尝试新规则之前,请清除浏览器缓存。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM