Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Search Engine Optimization (SEO) Search engine optimization , Google , Alexa , Yahoo , Site map , Spiders , Crawl , XML.

Search Engine Optimization (SEO) Thread, Mod rewrite tips and tricks in Marketing, Website and Domains; Mod rewrite tips and tricks Tip 1 instant 301 from old dynamic url to new static url (will only work ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6995


Closed Thread
LinkBack (3) Thread Tools Display Modes
Mod rewrite tips and tricks
 
 
The God Father
Developer's Avatar

 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
04-12-2008, 05:44 AM
 
Mod rewrite tips and tricks


Tip 1
instant 301 from old dynamic url to new static url
(will only work if you use the exact variables from the dynamic url)

Old dynamic url:
Code:
http://www.somesite.com/catalog.php?...roduct_id=1234
New static url:
Code:
www.somesite.com/catalog/widgets-1234.html
Code:
#start .htaccess code
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^cat\=([^&]+)\&product_id\=([^&]+)$
RewriteRule ^$ /catalog/%1-%2.html [R=301,L]
Reg Expression notes:
[^&]+ mean find any character except the "&" since it is what seperates the variables in a string. you can back reference matches in a rewrite condition using ()'s just like your rewrite rules but to call them you have to use a % instead of a $.

Benefits:
1. You don't have to hand write 1,000's of 301 redirects

2. Spiders can easily pick up the 301 and pass the scores and index the new urls much faster than having to crawl the entire site over from scratch.

3. Users clicking old dynamic urls in the SERPS will not get a 404 error. They'll go straight to the new static urls.

Tip 2

Change a product name or change a mispelling and you've just lost all page scores to the static mod rewritten url. Unless...

Example url:
www.somesite.com/dinnerplates/cassa-stone/
Should be spelled
www.somesite.com/dinnerplates/casa-stone/

Code:
RewriteEngine On
RewriteBase /

# detect if the file being requested is a mispelling
RewriteCond %{REQUEST_URI} /.*cassa.*$
#redirect to the correct spelling using a 301
RewriteRule ^(.*)cassa(.*)$ /$1casa$2 [R=301,L]
Reg Expression notes:
.* means match any character 0 to infinite times. so .*cassa.* so zzzzcassazzzz would be a match as well as /cassa-stone/. All I'm doing is back referencing everything before and after cassa and then copying it into the new url and doing a redirect.

Benefits
This can really save your @$$ nuff said. Egypt.Com EnForum

Tip 3

Make the unormalized, normalized for Yahoo!'s sake.

Example code:
<a href="some-directory/">some directory</a>

All bots and SE's are different. ugh. Google is very good at indexing and scoring exactly what is in the <a href> tag whether the url is normalized or not. Yahoo on the other hand is a stickler for normalization and will index the example above like so in there SERPS http://www.somesite.com/some-directory

to keep a 404 from kicking in if some-directory needs to be picked up by your mod rewrite make sure you end all your RewriteRules that end their mathcing on directory/folder like so.

Code:
RewriteRule ^([^/]+)/?$ /somepage.php?name=$1 [L]
who thought a question mark would ever be an answer Egypt.Com EnForum
? mean match the previous character 0 to 1 times. and will fix any normalization problems you might have encountered with Y!.

Code:
#This will send you into a horrible loop and bad thing may happen
#so don't use this
RewriteRule ^(.*)$ /somepage.php?name=$1 [L]
Benefits
1. users will not hit a 404 when clicking a yahoo SERP Egypt.Com EnForum

2. worth its weight in gold!

3. Your site will not look like a bad cloak hehe
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Closed Thread

Search Engine Optimization (SEO) Thread, Mod rewrite tips and tricks in Marketing, Website and Domains; Mod rewrite tips and tricks Tip 1 instant 301 from old dynamic url to new static url (will only work ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6995


Bookmarks

Tags
mod, rewrite, tips, tricks


LinkBacks (?)
LinkBack to this Thread: http://forum.egypt.com/enforum/search-engine-optimization-seo-f153/mod-rewrite-tips-tricks-6995.html
Posted By For Type Date
SEO friendly URL or Pretty URL using Apache mod_rewrite - a knol by Rajamanickam Antonimuthu This thread Refback 04-09-2009 06:54 AM
SEO friendly URL or Pretty URL using Apache mod_rewrite |QualityPoint Technologies This thread Refback 20-08-2009 11:11 AM
Mod rewrite tips and tricks This thread Refback 02-08-2009 03:11 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile myspace/facebook mod-rewrite Developer Mods for 3.7.x 0 02-11-2008 09:53 PM
TfSEO 2: the free vBulletin url rewrite Developer Mods for 3.7.x 0 01-11-2008 10:48 PM
Rewrite eBay Links Developer Mods for 3.6.x 0 30-10-2008 04:31 AM
Rewrite eBay To ShoppingAds Developer Mods for 3.6.x 0 10-10-2008 02:43 PM
MySpace Profile Rewrite Developer Mods for 3.7.x 0 18-09-2008 09:13 AM