How to redirect your websites..

Use at your own risk. even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.

Point an entire site to a different URL, such as domain.net redirected to domain.com:
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://db.iwhic.com/
 
Redirect index.html to a specific subfolder:
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://iwhic.com/newfolder/
 

Redirect an old file to a new file path:

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://iwhic.com/newdirectory/newfile.html
 

Redirect to a specific index page:

# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html
 

Redirect users to access the site without www:

# To redirect all users to access the site WITHOUT the www. prefix,
# (http://www.iwhic.com/... will be redirected to http://iwhic.com/...)
# adapt and uncomment the following:

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

 

Redirect users to use www:

# To redirect all users to access the site WITH the www. prefix,
# (http://iwhic.com/... will be redirected to http://www.iwhic.com/...)
# adapt and uncomment the following:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://www.iwhic.com/$1 [L,R=301]
 
Redirect viewers of your domain to use the secure version of your domain:
# An easy to way to always redirect the user to secure connection (https://) can be accomplished with the following lines:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.iwhic.com/$1 [R,L]
 
Redirect users to use https:// for a particular folder:
# In case you wish to force HTTPS for a particular folder you can use the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.iwhic.com/somefolder/$1 [R,L]
 
 

 

  • 3 Users Found This Useful
Was this answer helpful?