PDA

View Full Version : Dynamic to Static Redirect & Other SEO Q's


perpetuallylost
07-18-2007, 12:37 AM
I've scoured the web for a solution to my problem but haven't found one that works for me.

My site has close to 1,000 products on it. Once they are added, the database dynamically creates their product page urls as this: "site.com/detail.php?prod=abcd1234".

I have found two rewrite rules where the product can be accessed at a more friendly url - "site.com/abcd1234" that works at both these rewrite rules below...which is 'more correct' or better?


RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)(/)?$ /detail.php?prod=$1 [L]



RewriteEngine on
RewriteRule ^/?([A-Za-z0-9]+)(/)?$ /detail.php?prod=$1 [L]


However, the same product is still accessible via both urls and I don't want it to be. I am having trouble writing a redirect rule for this so that if someone does attempt to access a product through the old dynamic url "site.com/detail.php?prod=abcd1234" they are instead sent to "site.com/abcd1234". I don't want to have to create a redirect rule for each product either. So far I've either managed to either send the site through an endless loop or just redirect to the homepage.

That is the biggest issue I am having a problem with.

Another thing that I'd like to address is the fact that my site is available through several different urls:
http://www.site.com
http://www.site.com/index.php
http://site.com
http://site.com/index.php
https://www.site.com
https://www.site.com/index.php
https://site.com <- although technically the SSL certificate isn't valid without the 'www', the site data still loads.

I want visitors to continue to be able to access the site through any of these urls, but I don't want them all indexed by search engines. I would like them to be able to type in any of the urls above and use one of the urls as a main url to redirect the others to.

My questions are:
1. which of the urls above is the best to use from the SEO perspective, or does it not matter?
2. How would I write the redirect rule for all the above urls to work but redirect to 1 of the urls, and keep all the urls except for that one from being crawled by search engines?
3. Because my site uses SSL (it is only necessary for login, cart, & checkout process) would using this type of rule interfere with using SSL https?

I know this is a bunch of questions, but if anyone well versed in htaccess rules and SEO would help me out, I would be eternally grateful.

Thank you

Jazajay
07-18-2007, 01:54 AM
You will need two rewrites first to remove index.php to just / and second to have all the domain names redirect to www.site.com.

1.RewriteCond %{THE_REQUST} ^GET\ .*/index\.(php|html)\ HTTP
RewriteRule ^(.*)index\. (php|html)$ /$1 [R=301,L]

This redirects all index.php/html to www.site.com

2.RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.site\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This redirect will redirect any url that isn't www.site.com to www.site.com

I do not know about SSL and mod_rewrite sorry but from an seo point shorter urls are better that is why i wrote it to redirect to .com rather than .com/index.php.

Hope i've helped

perpetuallylost
07-18-2007, 03:46 AM
I appreciate your help, but your codes just popped up '500 Internal Server Error'

Can anyone help with my other problems?

TIA

SanDiegoSEO
07-18-2007, 01:26 PM
You're likely going to need to redirect all 1000 old URL's to the new URL's. Its not a problem to leave the original string accessible. Since nothing on your site will link to it, it will eventually fall out of the results or go supplemental. I like to leave the original strings functional just incase someone as it linked or bookmarked.

Jazajay
07-19-2007, 05:53 AM
Hi
I've just tested the code on my site and it works fine. I will provide you with my url if you need so you can see for yourself.

On my site www.example.co.uk/index.php will re-direct to www.example.com/(this is not my url)

The code is (this is just copied straight from my htaccess file as to make sure i do not make any mistakes in the code, it should work fine.)

RewriteEngine on

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

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php)\ HTTP
RewriteRule ^(.*)index\.(php)$ /$1 [R=301,L]

obviously change example to site for it to work properly for you.

If you need my url i'll happily email it so you can see for yourself.(I would provide it but it's totally s**t at the mo as i'm in no rush to finish)
But cant see why it shouldn't work.
Hope this helps
if it does not copy and paste the exact code from your htaccess.
Let me know either way.

Jazajay
07-19-2007, 06:10 AM
Hi
One other thing if you can you would want the urls to display as

www.site.com/sheep

rather than

www.site.com/abc3456

if you sell sheep that is as this gives you a keyword in your url
And this can improve click thoughs aswell as (....com/sheep says what you are selling and ....com/abc3456 could be anything).

In response to your ssl to be honest it'll probly would be detrimental for you to include them anyway. This is because SE`s will follow several links to your cart which will probly result in you being penalized for duplicate content.

Login again will not be needed for SEO as there is no relevant content. unless you provide the content via cloaking like the New York Times. But if you go down the cloaking route you can run the risk of being penalised as search engines are only intressted in visable (yes i know invisable site factors such as page structure can play a part but on the whole visable factors are as us brits say the dogs bollo*ks).

So just leave them as they are i cant see it making a difference. if the rules do provide a problem with ssl i will eat humble pie. I would be intressted to hear if anyone has had problems but i cant see it being a problem. I hope this is what you ment.

Anyway let me know if it has fixed your problem.

BuckfastMonk
07-19-2007, 08:30 AM
:D nice title Jazajay. lol

Jazajay
07-19-2007, 12:22 PM
Cheers i'm on my way to becoming a man sometime in 2010 so i'll let you know how i get on. lol