Hello Friends,
Today i faced a situation where i need to redirect dynamic URL of my shopping cart to static url. I have changed the Dynamic URL(with query string , ? and &) to static one in my sunshop shopping cart. But still if i will open dynamic url with query string than it shows the content. This is a big issue with search engine as they will consider this dynamic page and static page as two different page and duplicate content issue araise.
Redirect 301 rule in .htaccess (which is below) is common rule everybody knows.
Using .htaccess
redirect 301 http://www.domain.com/about-us.html http://www.domain.com/about.htmlUsing PHP
<?php
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.domain.com/about.html” );
?>
What i want is to redirect dynamic urls(with query string , ? and &) to static page. For e.g. If i want to redirect http://www.domain.com/content.php?a=1&b=2 to http://www.domain.com/content.html than look at the below htaccess rules.
RewriteCond %{HTTP_HOST} ^domain.com
RewriteCond %{QUERY_STRING} ^a=1&b=2$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/content.html [R=301,L]
Add the above three lines and change the domain name and query string as per your need. Now whenever you will enter http://www.domain.com/content.php?a=1&b=2 , it will redirect to http://www.domain.com/content.html. So now Search engine will consider both as one page and duplicate content issue will not araise.
To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below.
You will get updates via email about every tutorial posted on this site . It will not take more than a sec.
[PHP Freelancing India]:D
0 comments:
Post a Comment
Any Questions or Suggestions ?