Knowledgebase: Site Functions
Cheat Sheet for .htaccess
Posted by on 18 August 2013 08:18 PM

Linked Resources for .htaccess Reading

Here are some great resources to help you wade through .htaccess:

Redirect Links to 'WWW'

Some site owners are concerned that users should always be redirected from sitename.com to www.sitename.com, or from mainsitename.com/addon to sitename.com. This can affect cookies and more. IBBoard solved this issue with some .htaccess lines:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.ibboard.co.uk$
RewriteCond %{THE_REQUEST} !^[^\]+\ /foldername(\?.*)?\ .*$
RewriteRule ^(.*)$ http://www.ibboard.co.uk/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www.ibboard.co.uk$
RewriteRule ^$ http://www.ibboard.co.uk/ [R=301,L]

Make sure that the host doesn't match and that the request isn't just the current folder without a trailing slash (OR the current folder without a trailing slash with a query string). Then, do a rewrite rule on that. The next rule catches the host not matching, but the request being /ibboard (for example: accessing www.hwtskins.co.uk/ibboard and not www.hwtskins.co.uk/ibboard/). Both rules then rewrite the request to use the required domain. The two rules are required as a single rule with only the %{HTTP_HOST} condition causing requests to be incorrectly rewritten.
(1 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion