301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It’s not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it’s the safest option. The code 301 is interpreted as “moved permanently”.
Tag Archives: htaccess
Htaccess Cache Specifics files
Using Htaccess file you can speed up the loading time of your site with Header and ETag.
Example
Header unset ETag FileETag None # 21 DEC 2012 <filesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$"> Header unset Last-Modified Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT" Header set Cache-Control "public, no-transform" </filesMatch> # 3 HOUR <filesMatch "\.(txt|xml|js|css)$"> Header set Cache-Control "max-age=10800" </filesMatch> # NEVER CACHE <filesMatch "\.(html|htm|php|cgi|pl)$"> Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate" </filesMatch>
Speed up your site with Caching and cache-control
Caching with .htaccess and Apache will take your website and your web skills to the next level. This is some technical and advanced methods condensed to simple htaccess code examples for you. But you must take the time to understand caching with cache-control and other headers and HTTP options before you implement on a production server.
htaccess how to redirect to www or not
An important thing to know with the .htaccess file is how to have a site with always the www prefix (http://www.mydomain.com) or without (http://mydomain.com).
To do that you need to use a 301 redirect, here there are the two examples:
from http://mydomain.com to http://www.mydomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
from http://www.mydomain.com to http://mydomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]