Warning |
---|
This article is in quick note form and needs to be flushed out into an article. |
For this website both the urls,
http://bonsaiframework.com and http://www.bonsaiframework will work.
However, in In some cases you want to force what a consistent url for a variety of reasons,
- Vendor or product code that works with only a specific url.
- Improve index results from search engines
This can be accomplished using Apache's Rewrite.
This website uses this feature where http://bonsaiframework.com will redirect to http://www.bonsaiframework.com
Enable Rewrite Module
With Ubuntu this is very easy,
Code Block | ||
---|---|---|
| ||
sudo a2ensite |
Will result in showing a list of modules that you can enable. You want to enable rewrite. If it is not there than it might already be enabled.
...
Apply Directives
Code Block | ||
---|---|---|
| ||
# Enforce www in front of url. RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.bonsaiframework\.com$ [NC] RewriteRule (.*) http://www.bonsaiframework.com$1 [R,L] |
...