Home > .htaccess > 301 Redirect old dynamic URLs to new static URLs using .htaccess

301 Redirect old dynamic URLs to new static URLs using .htaccess

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.html

Using PHP
<?php
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.domain.com/about.html&#8221; );
?>

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.

Advertisements
Categories: .htaccess Tags: ,
  1. Kelly Done
    July 4, 2011 at 12:48 am

    This was a very helpful article! Have a good day!

  2. December 6, 2013 at 1:59 pm

    Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted to get
    guidance from someone with experience. Any help would be enormously appreciated!

  3. January 18, 2014 at 8:45 am

    Definitely believe that which you stated. Your favorite
    justification appeared to be on the internet the easiest
    thing to be aware of. I say to you, I definitely get irked while people consider worries that they just do
    not know about. You managed to hit the nail upon the top and
    defined out the whole thing without having side-effects ,
    people could take a signal. Will likely be back to
    get more. Thanks

  4. full movie catching fire
    February 8, 2014 at 11:06 am

    My brother suggested I might like this blog. He was totally right.
    This post actually made my day. You can not
    imagine simply how much time I had spent for this information!
    Thanks!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: