302 redirect but leave the url intact

302 redirect but leave the url intact - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about redirects, htaccess, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


Am I able to issue a 302 redirect but leave the URL intact?



I want to track accesses to a URL in Google Analytics but just display my home page.



I am doing this on the assumption that Google Analytics tracks the URL in the address bar - is this correct?



i.e.



www.example.com/landingpage


google sees URL of www.example.com/landingpage



user sees content from www.example.com (home page)


Solution :

To begin with, a 302 redirect does not do what you want on a functional level. A correct 302 redirect will actually redirect you from www.example.com/landingpage to www.example.com. That means the user will see www.example.com in the address bar and Google will as well.



In order for you to have two URLs with the same content you would need to duplicate the content which is bad from an SEO standpoint for 2 reasons:




  1. Google will see it as duplicate content and possibly mark it as spam or just downgrade it for being duplicate

  2. Both www.example.com/landingpage and www.example.com will compete with each other for the same keywords and SERPs which means you essentially split the SEO value of your pages in half.



In general if you want someone to go to www.example.com/landingpage and see the content on www.example.com you would do a 301 redirect which is a permanent redirect.



The other solution is to use a canonical link tag like this, <link rel='canonical' href='http://www.example.com/' /> on the page, www.example.com/landingpage. This works because it tells Google that the content is duplicate or very similar and which page is the correct page to show when someone searches for terms found on both pages and at the same time lets you use www.example.com/landingpage as a landing page for paid ads for example.



A 302 redirect is generally for temporary redirects or redirects for unspecified reasons. In general Google does not give you any benefit for 302 redirects.



See this, http://en.wikipedia.org/wiki/302_redirect#HTTP_status_codes_3xx for more info on what all redirect types mean.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect