Databases for Sale


| Home Page | Best Offer! | Contact Us | Databases and Software For Sale | Read Our Blog |

Mod-Rewrite For SE Friendly URLs - A Practical Example

- June 15, 2009, 8:57 pm | Coding Tips

Add to mod rewrite htaccessdel.icio.us | Mod Rewrite For SE Friendly URLs   A Practical ExampleDigg


We get a lot of questions about how to use Mod Rewrite on their Unix Platform web site, so they can eliminate query expressions in their url and make it Search Engine Friendly. (From query.php?keywords=mod rewrite to mod rewrite.htm)

mod rewrite htaccess

This will be a quick lesson with a script we use all the time.

Most applications that use our databases use a simple query format: query.php?keywords=something here

This simple query is presented in the mod rewrite code as query.php?keywords=$1

So to begin, be sure to always add these two lines in your .htaccess file:

Options +FollowSymLinks
RewriteEngine On

Your next line will take the URL

[yourdomain.com/mod rewrite.htm]

and rewrites it on the Server Side to

[yourdomain.com/query.php?keywords=mod rewrite]


The entire code, which is placed into your .htaccess file is:

Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*).htm$ query.php?keywords=$1


There are many variables available in Mod Rewrite, but this should give you a basic format to begin with.

By having this code in your .htaccess file you can now use SE Friendly URLs. So `yourdomain.com/roses.htm` and `yourdomain.com/furniture polish.htm` will be converted on your server and deliver content from your database about `roses` and `furniture polish`.


And to give you something a little more advanced, we will leave you with the following mod rewrite code. Understanding the above information should give you a good base of understanding from which to understand the following:


Options +FollowSymLinks
RewriteEngine on


RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3+$4+$5 
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3+$4
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2 
RewriteRule ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1
RewriteRule ([a zA Z]+)/$ search.shtml?keywords=$1
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3+$4+$5 
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3+$4
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+).htm$ search.shtml?keywords=$2






Keywords: mod rewrite htaccess
Articles on mod rewrite htaccess News on mod rewrite htaccess Videos on mod rewrite htaccess


Recently Added:
  1. Problems With Variables Not Being Passed To A Page - Coding Tips
  2. 12,000,000 Page Web Site - 12 Million Page Web Site
  3. Converting CSV Files To SQL The Easy Way - Working With Data
  4. Mod Rewrite For SE Friendly URLs A Practical Example - Coding Tips
  5. Read This Before You Buy A Database - Database Notices

Blog Categories:
12 Million Page Web Site
Coding Tips
Database Notices
Working With Data

Our Shop:
Business Contact Databases
Business Databases
Database Collections
International Databases
Misc Databases
Niche Databases
Optin Email
Resellers
Residental White Pages
Software
Software and Databases
Zip Code Databases


Documents:
Frequently Asked Questions
Privacy Notice
Return Policy
Terms and Conditions

| Home Page | Best Offer! | Contact Us | Databases and Software For Sale | Read Our Blog |

Copyright © 1993-2009 USPN Tech, All Rights Reserved