miholzi
miholzi

Reputation: 994

multiple htaccess rewrite Conditions / angular routes html5 mode

i have a angular project with routes in html5 mode. I set up a htaccess file, that is possible to insert a domain manually or refresh the page.

here the htaccess code with works fine, based on this Still getting 'Not Found' when manually refreshing with angular.js route

    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:

http://example.com should become 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!

Upvotes: 1

Views: 734

Answers (1)

Panama Jack
Panama Jack

Reputation: 24448

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.

 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.

Upvotes: 1

Related Questions