1

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!

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.