Hi Ray,
This is great (assuming that the two domains share the same DocumentRoot - I believe that you had confirmed somewhere above that they do; in cPanel, that’s called “Parked” domain).
I’ll go through your .htaccess and add notes as comments after saying that long .htaccess files are not a good thing AND you should test then REMOVE all your <IfModule> tests as they are wasteful. Remember, the .htaccess file is read and parsed MULTIPLE times for every FILE request!
#
#
# Trade-th.com
# AND Classified-Thailand.com
#
# (c) 2011 Trade-th.com
#
#
[COLOR="#808080"]<IfModule mod_deflate.c>[/COLOR]
# DEFLATE by type - html, text, css, xml
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml
# DEFLATE by type - javascript
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/x-js text/x-javascript
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
[COLOR="#808080"]</IfModule>[/COLOR]
## Uncomment this if FollowSymLinks is not already enabled on your server
#Options +FollowSymLinks
## Use mod rewrite
## Comment the line below if RewriteEngine not already enabled on your server
RewriteEngine On
## Uncomment the line below and change the path if your script is installed
## in a different path than the root folder of your domain
RewriteEngine On
[COLOR="#808080"]RewriteBase /[/COLOR]
# What's that supposed to do? It changes the location of files which are "moved" as a result of
# Redirect statements so I'd recommend commenting this out
# Removes www from trade-th.com
# If you're redirecting from trade-th to classified-thailand, WHY BOTHER?
RewriteCond %{HTTP_HOST} ^www\\.trade-th\\.com [NC]
RewriteRule ^(.*)$ http://trade-th.com/$1 [L,R=301]
[COLOR="#808080"]RewriteEngine on[/COLOR]
# Only one statement is necessary to ensure mod_rewrite is not in the comment mode
[COLOR="#808080"]Options +FollowSymLinks[/COLOR]
# Normally in httpd.conf - test then remove
RewriteCond %{THE_REQUEST} [COLOR="#FF0000"]^[/COLOR].*/index\\.html
# {THE_REQUEST} starts with the HTTP version identification so you've got to get rid of the start anchor
RewriteRule ^(.*)index.html$ http://www.trade-th.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/index\\.php
RewriteRule ^(.*)index.php$ http://www.trade-th.com/$1 [R=301,L]
# First, you've GOT to split the line with the RewriteCond.
# Second, you don't need the RewriteCond statements if you simply use the + (one or more) metacharacter
# rather than the * metacharacter (zero or more)
# Third, you're making a circular redirection back to WWW.trade-th.com!?!
[COLOR="#808080"]RewriteBase /[/COLOR]
# Second time when ZERO times is my recommendation
# For the following RewriteRules, the No Case flag is quite inappropriate (unless coming from a WinDoze server).
# Consider using the R=301 flag IF (and ONLY if) you want the redirection to be seen by the browser
# Rather than a ridiculous list like this (especially with the pseudo-directories), try RewriteRule (.+)\\.html$ $1.php [L]
# The point to this is to actually use the real power of mod_rewrite: Regular Expressions
# Is there a reason for all the Query String Appended flags (are you expecting a pre-existing query string)?
RewriteRule ^index.html index.php [nc]
RewriteRule ^recent_ads.html recent_ads.php [nc]
RewriteRule ^register.html register.php [nc]
RewriteRule ^pre-register.html pre-register.php [nc]
RewriteRule ^login.html login.php [nc]
RewriteRule ^logout.html logout.php [nc]
RewriteRule ^favorites.html favorites.php [nc]
RewriteRule ^contact.html contact.php [nc]
RewriteRule ^listings.html listings.php [nc]
RewriteRule ^pre-submit.html pre-submit.php [nc]
RewriteRule ^([0-9]+)-([^\\/]+)?/content.html$ content.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/index.html$ index.php?category=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/details.html$ details.php?id=$1 [nc,qsa]
RewriteRule ^([^\\/]+)/([^\\/]+)/([^\\/]+)/recent_ads.html$ recent_ads.php?page=$1&order=$2&order_way=$3 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/user_listings.html$ user_listings.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/([^\\/]+)/([^\\/]+)/([^\\/]+)/user_listings.html$ user_listings.php?id=$1&page=$3&order=$4&order_way=$5 [nc,qsa]
RewriteRule ^([^\\/]+)/([^\\/]+)/([^\\/]+)/favorites.html$ favorites.php?page=$1&order=$2&order_way=$3 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/store.html$ store.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\\/]+)?/([^\\/]+)/([^\\/]+)/([^\\/]+)/store.html$ store.php?id=$1&page=$3&order=$4&order_way=$5 [nc,qsa]
# For the rules with the pseudo-directories, remember that the browsers
# will be looking for your image, css, js and other support files at the
# WRONG directory level - see my signature's tutorial and look for the <BASE> tag solution.
## Uncomment the following line when activating location subdomains
## Don't forget to replace yourdomainname.com with your own domain name !
#RewriteCond %{HTTP_HOST} !www.trade-th.com$ [NC]
#RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-_]+).trade-th.com [NC]
# Subdomains, too?
#RewriteRule (.*) %{SCRIPT_FILENAME}?crt_city=%2 [NC,QSA]
# Is that an optional {SCRIPT_FILENAME} or are you trying to access the {QUERY_STRING}?
RewriteCond %{REQUEST_URI} ^(.*)(/listings.html)(.*)$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) ./listings.php?$1
# That seems like too much work to simply change listings.html to listings.php. Are there pseudo-directories to be concerned with?
# Redirection to .listings.php with a query string?
[COLOR="#808080"]RewriteEngine On[/COLOR]
# Ditto (again)
# Redirect www.trade-th.com to www.classified-thailand.com. What about the non-www'd trade-th.com? Subdomains?
RewriteCond %{HTTP_HOST} ^trade-th.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.trade-th.com$
RewriteRule (.*)$ http://www.classified-thailand.com/$1 [R=301,L]
# .htaccess in DocumentRoot of both trade-th.com and classified-thailand.com
# The following looks familiar BUT is grossly out of place!
# mod_rewrite code only - you can take care of your DirectoryIndex, Options -Indexes, ErrorDocument, etc.
[COLOR="#808080"]RewriteEngine on[/COLOR]
# Ditto (again)
# force www.classified-thailand.com (#1 & #1a) -- SHOULD BE FIRST mod_rewrite (then forget about domains)
RewriteCond %{HTTP_HOST} !www\\.classified-thailand\\.com$ [NC]
RewriteRule .? http://www.classified-thailand.com%{REQUEST_URI} [R=301]
# Redirect 26-colloidal-silver-15-ppm-spray/details.html to 16-colloidal-silver-15-ppm/details.html (#2)
RewriteRule ^26-colloidal-silver-15-ppm-spray/details\\.html$ 16-colloidal-silver-15-ppm/details.html [R=301]
# I'm still not sure whether you're using index.php or details.php (or {whatever}.php as your DirectoryIndex (file handler)
# The Missing Link! Redirect non-directory requests to details.html in DocumentRoot with dir={value of the non-directory}
RewriteCond %{REQUEST_FILENAME} ^([-a-z0-9]+)/details\\.html$
RewriteCond %{DOCUMENT_ROOT}/%1 !-d
# I don't think you need the / but I put it in here for you to test and report back, if you would be so kind
RewriteRule ^([-a-z0-9]+)/details\\.html$ details.html?dir=$1 [L]
Ray, I tried to be rather pedantic in my comments but, despite the large number of comments, it seems as if you have a semi-grasp of mod_rewrite. PM with specific questions.
Regards,
DK