PHP Code:
#The "Category" text here needs to be changed if the language variable category is changed
RewriteRule ^Category\/(.+)/$ index.php?id=$1
RewriteRule ^Category\/(.+)/([0-9]+)\.html$ index.php?id=$1&page=$2
#Handle all location links. Static location text followed by ID, followed by path
#The "Location" text here needs to be changed if the language variable location is changed
RewriteRule ^Location\/(.+)/$ index_locations.php?id=$1
RewriteRule ^Location\/(.+)/([0-9]+)\.html$ index_locations.php?id=$1&page=$2
#Handle Custom Module Pages
RewriteRule ^view-(.+)\.html$ module_page.php?moduleid=$1
#Ignore any physical files
#Handle all listing links. Listing ID followed by listing name or corresponding pages.
RewriteRule ^out-([0-9]+)\.html$ listing_out.php?id=$1
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)\.html$ listing.php?id=$1
RewriteRule ^(.+)/gallery\.html$ listing_gallery.php?id=$1
RewriteRule ^(.+)/send-message\.html$ listing_email.php?id=$1
RewriteRule ^(.+)/send-message-friend\.html$ listing_email_friend.php?id=$1
RewriteRule ^(.+)/reviews\.html$ listing_reviews.php?id=$1
RewriteRule ^(.+)/add-review\.html$ listing_add_review.php?id=$1
RewriteRule ^(.+)/products-(.+)\.html$ listing_products.php?id=$1&type=$2
RewriteRule ^(.+)/documents\.html$ listing_documents.php?id=$1 [L]
</IfModule>
# handle links of affiliate Director 2.0
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/([a-z_\-]+)/?$ /ad2/redirect.php?site=$2 [NC,L]
ErrorDocument 404 /
ErrorDocument 403 /
ErrorDocument 500 /
RewriteEngine on
RewriteRule ^([^\.]*)?\.htm$ index.php?name=$1 [NC,L]
RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]
Index files in subdirectory are re-directed to root
Root
Subdirectory
subdirectory2