How To Redirect to HTTPS with .htaccess

preview_player
Показать описание
Learn how to redirect your website traffic from HTTP to HTTPS with the .htacces file. If you have ssh or FTP access to your Apache web server, you can modify your .htaccess file with a permanent 301 redirect to send all traffic to the HTTPS version of your website.

Code snippet:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
Header always set Content-Security-Policy "upgrade-insecure-requests;"

Check out my vlog channel @TonyFlorida

#https #htaccess #apache
Рекомендации по теме
Комментарии
Автор

I've just got my first VPS and you've been an angel to me.

antidotejack
Автор

nice tip, hey i have a question.... the AddType, is that the full path from the root folder? also, is this for all files except php?

foreign-livingtheamericand
Автор

merci beaucoup depuis la côte d'ivoire

axeltoure
Автор

for me still not working, any suggestions?

dodypod
Автор

I was using filezilla and vscode to edit htaccess. thanks tony

ravi-gadhiya
Автор

wow. you are great . i was using the code and i am successful . thank you so much . love from Bangladesh .

devmehedi
Автор

I got a notification in Google Analytics saying that my property is getting traffic from multiple host names (www and non www urls). This happened after I switched hosting from Bluehost to Cloudways. The solution Google gives is to create a 301 redirect in the .htaccess file. Any thoughts on why this happened and do you happen to know how to add this particular 301 redirect? Thanks Tony!

justinchildressofficial
Автор

After Using the code my site goes like below... This creates two 301 redirects... Can someone tell me what's happening?

301 Moved Permanently
>
301 Moved Permanently
>
200 OK

wzafar
Автор

I think the redirect through Cloudflare dns is faster. What do you think ?

ronak
Автор

How about. HTTPS to HTTP Sir? revert back

cjkjhij
Автор

sorry the site says the page has redirected you too many times.

noticedcloud
Автор

Have to put .htaccess file in every directory ??

kshirodhati
Автор

What is it that we need to learn to write instructions such as these to modify how the web server operates? Thanks

muhaasibjamaal
Автор

Well, that didn't work. made the site inaccessible until I deleted the snippet.

howyadoing
Автор


# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* -
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Please advise

howyadoing