Page 1 of 1

.htaccess file for SEO

Posted: Thu Jun 23, 2011 1:54 pm
by vinyl
How can you edit the normal .htaccess file to rewrite the URL so that "WWW" is always put in front of the URL?

To make it even better, I use a subdirectory for my installation.

My current file looks like this:

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /2011

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

<IfModule mod_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</IfModule>

<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>

<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
  # Setting cache control to public allowes proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</FilesMatch>
I tried adding this:

Code: Select all

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
But than I end up in the web root folder and not in my sub folder.. Any one that has a clue on how to get this working?

Re: .htaccess file for SEO

Posted: Thu Jun 23, 2011 4:00 pm
by Rolf
You will find more info here: http://forum.cmsmadesimple.org/viewtopic.php?t=36912

grtz. Rolf :)