Difference between revisions of "Mod rewrite"

From Hostek.com Wiki
Jump to: navigation, search
(Created page with "==General Information== Mod rewrite is available on our Linux servers and can be used to rewrite or redirect your site to a particular URL. ==Redirecting to a Sub Folder== <p...")
 
Line 10: Line 10:
 
</pre>
 
</pre>
  
 +
==HTTP to HTTPS==
 +
<pre>
 +
RewriteEngine On
 +
RewriteCond %{HTTPS} off
 +
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 +
</pre>
 
[[Category:Linux]]
 
[[Category:Linux]]

Revision as of 01:40, 13 August 2013

General Information

Mod rewrite is available on our Linux servers and can be used to rewrite or redirect your site to a particular URL.

Redirecting to a Sub Folder

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

HTTP to HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}