SEOCentro
Search SEO Blogs Archive:

Search SEO Posts Last 14 Days





Redirect non existing inbound links with mod rewrite

(Page 4 of 6)

Redirect non existing inbound links to existing urls for recapturing PageRank and retain visitors who might be lost by an unexpected 404 (Not Found) error code. Below is a routine that correct most of the badly-coded and/or commonly misspelled internal and inbound links.
RewriteEngine On

#+---------------------------------
#+ - BEGIN: URL fixup redirect routine
#+---------------------------------

# Get the requested URI, query string and hostname.
RewriteCond %{REQUEST_URI} ^(/[^?]*)([?].*)?$
RewriteRule . - [E=myUri:%1,E=myQuery:%2]

# Replace hmtl, htlm, and thml file extensions with html extension.
RewriteCond %{ENV:myUri} ^(.*)[.,](hmtl|htlm|thml)$ [NC]
RewriteRule . - [E=myRedirect:yes,E=myUri:%1.html]

# Replace comma(s) or multiple filetype delimiter periods in the url
# with a single period.
RewriteCond %{ENV:myUri} ^(.*)([,.]{2,}|,)((s?html?|php[1-9]?|aspx?|pdf|xls).*)$ [NC]
RewriteRule . - [E=myRedirect:yes,E=myUri:%1.%3]

# Remove invalid trailing characters
RewriteCond %{ENV:myUri} ^([/0-9a-z._\-]*)[^/0-9a-z._\-] [NC]
RewriteRule . - [E=myRedirect:yes,E=myUri:%1]

# Remove trailing punctutation
RewriteCond %{ENV:myUri} ^(.*)[._\-]+$
RewriteRule . - [E=myRedirect:yes,E=myUri:%1]

# Do the external 301 redirect only if needed and the resource exists
# at the corrected URI.
RewriteCond %{ENV:myRedirect} ^yes$ [NC]
RewriteCond %{DOCUMENT_ROOT}%{ENV:myUri} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{ENV:myUri} -d
RewriteRule . http://www.example.com%{ENV:myUri}%{ENV:myQuery} [R=301,L]

#+---------------------------------
#+ - END: URL fixup redirect routine
#+---------------------------------
EXPLAIN: The routine fixup multiple mistakes at ones and redirect only one time when mistake(s) where found.

NEXT » Search engine friendly urls with mod rewrite



Article Index
1. Use mod rewrite for SEO purposes

2. Avoiding duplicate content with mod rewrite

3. Redirect relocated urls with mod rewrite

4. Redirect non existing inbound links with mod rewrite

5. Search Engine friendly urls with mod rewrite

6. mod rewrite for SEO purposes put together

Featured Sponsors




Sponsor SEOCentro

Featured Links
SEO Services
The SEO Company that is one stop for your Website Optimization.
1,000 One Way Links - $9.99
Get 1,000 backlinks for only $9.99. Money Back Guarantee!
Widexl SEO Programs
Search engine related programs for your website.
Sponsor SEOCentro

SEO Services
Latest SEO & Search Engine News
Latest seo and search engines blogs news for to stay up-to-date in the search engines marketing world.

Search Engine Optimization Tools
Online search engine tools, made available to help our visitors with their search engine strategy.

Search Engine Optimization
Responsible search engine optimization and ranking services to increase search engine positioning for your site.