need help with 301 redirect and seo urls - apache

Ok, i used the below to "seoize" my urls. It works great..the only problem is when i go to the old page it doesnt redirect to the new page.. so i have a feeling i will get two pages indexed in google... how can i just permenantly redirect the old pages eto new urls...
RewriteRule ^city/([^/]+)/([^/]+) /rate-page.php?state=$1&city=$2 [NC]
http: / / www.ratemycommunity.com/city/Kansas/Independence
and old page = http://www.ratemycommunity.com/rate-page.php?state=Kansas&city=Independence

The problem is that the ugly url must be visible, as you need them for the rewrite. Just don't make any links to the ugly urls.
If search engines already know about the ugly urls, you can add another query parameter, say show=yes.
In the rewrite rule, ensure that you have the last parameter show=yes. If not, redirect to the nice url, which in turn will rewrite to the ugly url with the last parameter. Then, never link externally to the ugly url with the show=yes parameter.
Example:
/rate-page.php?state=Somestate&city=Somecity&show=yes
Accessing this page will show the content, but you must not make that link visible from anywhere.
/city/Somestate/Somecity
should be rewritten to /rate-page.php?state=Somestate&city=Somecity&show=yes, and
/rate-page.php?state=Somestate&city=Somecity
should be redirected to /city/Somestate/Somecity

The best thing to do is use cannonicalization, a recently introduced page tagging concept that tells Google and other crawlers what you want to be the URL of record. Check out this documentation and video by Google SEO guru Matt Cutts.
In your case, it will look like this:
<link rel="canonical" href="http://www.ratemycommunity.com/city/Kansas/Independence"/>

Related

Manipulate user's address bar with mod_rewrite

I have a page at example.com/themizer.php, but I want it to appear that it's actually located at example.com/themizer/ (or example.com/themizer/index.php) for all practical purposes. I know how to basically make an alias for it with mod_rewrite, but how do I make it appear that users are being redirected to that alias? Example: a user requests example.com/themizer.php and the address in their browser turns into example.com/themizer/ without actually redirecting. Is this possible?
With server-sided configuration, you can only accomplish this with a redirect. This does not necessarily need to be a problem. Just make sure that the urls on your site point to the fancy url and not to the internal url. Otherwise you generate a lot of requests that have to be redirected, instead of just redirecting the odd request that came in in an other way (e.g. through an external old url or old bookmark). You do it like this:
#External redirect
RewriteCond %{THE_REQUEST} ^GET\ /themizer\.php\ HTTP
RewriteRule ^themizer\.php$ /themizer/ [R,L]
#Internal rewrite
RewriteRule ^themizer/?$ themizer.php [L]
If you really must, you can use javascript to 'push' a new window state into the history, updating the address bar. This causes the "go to previous page" button in your browser to contain bogus though. In other words: Going to the previous page does not work as expected, which I would not recommend since there is a better option available. You can do it with the following javascript statement in browsers that support it:
window.history.pushState( null, document.title, "/themizer" );

How to setup wild card 301 redirect that will remove URL parameters from index.php

ok I previously had some issues setting up a wild card redirect to strip parameters from an old url format that were non-seo friendly to our root. With the help of stackoverflow we've got it corrected and working but now I am experiencing issues with index.php?
Im seeing tons of duplicate urls in the engines using this url format index.php?cPath=# and Google is stressing me because they think its duplicate index pages.
I tried setting up this redirect in our htaccess but no go. It won't strip out the parameters or redirect it just duplicates the page with a valid 200 response.
RewriteRule ^index.php/.*$ /? [R=301,NE,NC,L]
I want to redirect anything with index.php?cPath=# to our root domain. Any ideas on how i can tackle this 301 redirect using a mod_rewrite on apache?
I've also just noticed that our site has another issue with this url format:
domain.com/?cPath=#...
so now I also need to write a rewrite for domain.com/?cPath=# I don't know where this one popped up from but I can see its going to cause issues hence the valid 200 response code it gives. The engines are really going to love me for this one.

301 Redirect in .htaccess for re-submitting URL-s

I want to ask how do I redirect Search Engines to take a second look on my new, fresh, rewritten URL-s?
So, my former URL-s were structured like this :
http://www.sample.com/tutorials.php?name=something
and now they look much more cleaner and better :
http://www.sample.com/tutorials/programming/something.php
So, as I said, I want Google (and other engines) to take a look at my new links, which are much more SEO friendly and for that I will be indexed better.
I was told the 301 redirect method was the best, but I don't have a clue what is it, how it works and where to learn how to use it. So, I am asking you.
Side note : Would updating my sitemap.xml file and re-submitting it to Google Webmaster Tools help in this process?
Thanks in advance!
There are 2 kinds (in this context) redirects. When a client, be it a browser, search engine indexing bot, or whatever, requests a URI, the server can tell the client "What you are looking for exists, but it's somewhere else". In the case of a 302 or temporary redirect, it's essentially telling the client "What you are looking for exists, but it's temporarily over here at this URL". In the case of a 301 or permanent redirect, it's essentially telling the client "What you are looking for exists, but it has permanently moved over to this URL".
In the case of the later, browsers, proxy servers, and search engine indexes know that the old URL is no longer valid and to stop using it, and from now on to use the new URL that was returned by the server via a 301 redirect. In the case of a search engine like Google, it has an index of the old URL and all the data that its accumulated over the lifetime of that URL assoicated with it. When one of its bots sees a 301, it knows that the old URL, and its content, isn't gone, but it just permanently moved to another URL. All of the associated data Google has collected for the old URL gets trasnfered to the new URL. Google can probably figure most of this stuff out without a 301 redirect, but it's a sure way to make sure Google has got a right.
You can do such a redirect via mod_rewrite:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /tutorials\.php\?name=([^&\ ]+)
RewriteRule ^ /tutorials/programming/%1.php [L,R=301]
You should put this near the top of the htaccess file in your document root. The condition checks that an actual request has been made for /tutorials.php with a query string name="something". The "something" part gets grouped by the match and is accessed via the %1 backreference.
The 301 redirect is a response that the server can make which signals to the user (or search engine) that the page they are looking for has been permanently moved to a specified other page. It is possible to configure apache to give a 301 for certain urls, but it is probably easier to have the whatever server-side language you are using take the request, and then issue a 301.
The chances are that Google will work out what is going on fairly quickly without 301s or anything else, but submitting a sitemap to them or using the URL Parameters functionality in Google's Webmaster Tools might help.

Apache RedirectMatch where destination URL contains Querystring?

I haven't found a solution to this, since all of my searching and research points to query string related issues when you're going from a file with a query string, over to another URL. In my case, I'm just looking to go from a regular folder/file, etc., to a URL with a query string.
I have a working .conf file which contains various rules for my site. I'd like to add in another one that looks like this:
RedirectMatch ^/webinar$ https://company.webex.com/company/onstage/g.php?t=a&d=123456
RedirectMatch ^/webinar/$ https://company.webex.com/company/onstage/g.php?t=a&d=123456
I've modified the URL to be more generic. This redirects properly when I type in www.company.com/webinar however, it's not going to the above URL. When I type in the above URL directly in a browser, it loads up fine.
The redirect is taking me to a generic Webex page. This could be an issue with the redirect, but I think it has to do with how RedirectMatch is handling the query string on this URL. I'm at a loss.
EDIT
There might be an issue in how I now have 3 redirects happening. The first is the /webinar, second is the above URL, and the third is that the above URL redirects to another page where quite frankly, webex may be handling iframes. Not 100% sure. So could the second redirect be borking the third, etc? I can provide more specifics as far as the webex URL's if required.
SOLUTION
The issue here is that Webex can't handle a double redirect which is what's happening. Instead, I had to leverage a PHP page with a header redirect in a separate folder off of the TLD. The above RedirectMatch syntax is correct, but for some reason, Webex borks it.

Massive URL Change

We need to make changes to an app that will cause all its URLS to change, we don't want to lose value, and have too many urls redirect to 301. I am looking to change a mod rewritten URL to a non-written one.
My thoughts would be to
Leave the mod rewritten URLS active (Temporarily)
Place a canonical tag with the NEW correct URL
Make sure no links are currently linking to old URLS - all internal links updated etc
Make sure our robots.txt and sitemap submissions are updated to date.
Would a massive change in URLs - even if backed up by canonical URLs and updated sitemap.xml - have a negative affect on listings in google?
What are peoples thoughts / experience in this?
Thinking about it, if you're using mod_rewrite and are wanting to switch to a non mod rewritten URL then the chances are you can make the changes purely by adding the 301 response to the end of your rewrite rule to make something like this:
RewriteRule ^whatever/(.*)$ http://www.domain.com/$1/ [R=301,L]
Actually, a 301 redirect should not impact your search ranking - it's exactly how you're supposed to do that kind of thing and it's search engine independant. The "canonical" header is an invention of Google and has the disadvantage that people still using the old URLs from outside links will not be redirected and thus keep using the old URLs in links and bookmarks.
Using a permanent HTTP redirect is the best solution for both, your users and the search engines.
I'd also be interested to know then on this topic how these 301's should be handled, in .htaccess or at a code level? Surely 100's of 301's in a .htaccess is too many?