Apache modifies the .htaccess file to enforce HTTPS address access

888u

Last update at :2024-07-09,Edit by888u

From the users we meet in daily life, we can see that if we use VPS or server users, they actually use Nginx more often and Apache less often. However, in terms of actual performance advantages and disadvantages, each has its own advantages. For general websites or projects, there is basically not much difference between the two. You can use whatever you like. Snail shared the article "Nginx environment forces http 301 jump to https setting record" in a previous blog post.

A friend here needs to use Apache to implement HTTPS forced redirection. The relative setup is a bit simpler than Nginx. Just modify the .htaccess configuration pseudo-static file corresponding to the root directory of the website.

First, root directory domain name

RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://www.ourdomain.com/$1 [R,L]

Second, subdirectory

RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteCond %{REQUEST_URI} Subdirectory folder RewriteRule ^(.*)$ https://www.ourdomain.com/Subdirectory folder [R,L]

According to our actual site domain name, set the .htaccess file added to the root directory of the current site to take effect.

Recommended site searches: Hong Kong vps, private server rental, Shanghai virtual host, virtual host provider, VIP domain name, space server, anti-attack IP, Hong Kong server rental, Korean high-defense server, mainland China proxy IP,

Apache modifies the .htaccess file to enforce HTTPS address access

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码