Databases for Sale


| Home Page | Contact Us | Databases and Software For Sale | Data Management Tips |

Mod-Rewrite For SE Friendly URLs - A Practical Example

- January 18, 2010, 3:10 am | 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. Converting CSV Files To SQL The Easy Way - Working With Data
  2. Mod Rewrite For SE Friendly URLs A Practical Example - Coding Tips
  3. Read This Before You Buy A Database - Database Notices
  4. Quickly Import Large CSV Files Into MySQL - Working With Data

Categories:
Coding Tips
Database Notices
Working With Data

Our Shop:
Business Databases
Database Collections
Misc Databases
Niche Databases
Optin Email
Residental White Pgs
Software
Zip Code Databases


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

| Home Page | Contact Us | Databases and Software For Sale | Data Management Tips |

Copyright © 1993-2009 ZattaMedia, All Rights Reserved