Showing posts with label HTTP Request. Show all posts
Showing posts with label HTTP Request. Show all posts

Friday, October 12, 2012

Change of Domain 301 Redirect htaccess



For SEO best practices, when you change domain name of existing website, we need to setup 301 redirect of all existing web pages exactly to a new domain name. This is very important for Search engines detect a new version of URLs

Using the following htaccess code we will redirect all the existing pages of our website to new.


RewriteEngine On
# Redirect all urls with new domain name
RewriteCond %{HTTP_HOST} ^domainone.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domainone.com$
RewriteRule ^(.*)$ http://www.domaintwo.com/$1 [r=301,nc]

# Redirect with www of new domain.
RewriteCond %{http_host} ^domaintwo.com [nc]
RewriteRule ^(.*)$ http://www.domaintwo.com/$1 [r=301,nc]

about code will redirect all the existing pages of current website to new website with same request URL.

Monday, June 11, 2012

redirect with WWW htaccess





If you need to redirect your domain name with "WWW" you can use the following htaccess code for Apache based web servers.


Redirect with WWW htaccess



Options +FollowSymLinks
RewriteEngine On

# Mention Domain name

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

# OR
# get domain name automatically.

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

Thursday, May 31, 2012

htaccess redirect with or without www


Developing SEO friendly website, you have to decide the domain name is whether it is with "WWW" or without "WWW". as per your need you can transform the user behavior by redirecting reversal order based on your need. If you decide without WWW mean, while user attempt to type with http://www.example.com you need to redirect http://example.com, If you decide with WWW mean, you need to redirect with www when user typing http://example.com to http://www.example.com

In this case, We have the great option in .htaccess to decide with or without WWW .
Here is the solutions for htaccess redirect with or without www

Examples with mentioning Domain Name

Redirect WWW to non-WWW or without WWW Domain Name:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Redirect non-WWW to with WWW Domain Name:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
Rewriterule ^(.*)$ http://www.example.com/$1 [R=301,NC]





Example with Suitable for any Website without mentioning the domain name:
(Suitable for any Website) no need to tell the domain name on code.

Redirect www to non-www (both: http + https)
if we need to do this for separate http and https:

Options +FollowSymLinks
RewriteEngine On

# if without https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# if https
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]


Redirect non-www to www (both: http + https)
if we need to do this for separate http and https:


Options +FollowSymLinks
RewriteEngine On

# if without https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# if https
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]




Saturday, February 25, 2012

Reduce HTTP Request with Data URI in PHP


A part of website optimization technique is Reduce no of HTTP Request when user attempt to open our Web page from our website. HTTP Request count is an important factor for Traffic worthy websites to make your web pages / websites more responsive on time. In this factor of HTTP Request optimization to reduce the HTTP request count of various images in our websites by Rewriting with Data URI Scheme. Data URI is the technology which is used to Reduce and Optimize HTTP request and response.



For example If you have a gallery section in your website. Gallery images are in two Sections one is Thumbnails and another one is actual images. in this case set of 5 Images will request 10 HTTP request every time the Page opens. in this case we can use Data URI with PHP to reduce this HTTP request 0, Data URI will cheat our server and retrieve the image data as plain code along with our standard HTML code.