Forum Moderators: phranque
RewriteRule ^catalog/(.*).html$ http://www.mydomain.com/product.php?article=$1
RewriteRule ^catalog/images/(.*)$ http://www.mydomain.com/images/$1 [L]
RewriteRule ^catalog/themes/(.*)$ http://www.mydomain.com/themes/$1 [L]
RewriteRule ^catalog/(.*)$ http://www.mydomain.com/$1 [L]
which is working.
However, up to now I used subdomain for different countries, e.g. es.mydomain.com us.mydomain.com etc.
I now added a new domain name myotherdomain.com and I want to have one simple .htaccess file to cover any domains.
RewriteRule http://(.*)/catalog/(.*).html$ http://www.mydomain.com/product.php?article=$2
RewriteRule http://(.*)/catalog/images/(.*)$ http://www.mydomain.com/images/$2 [L]
RewriteRule http://(.*)/catalog/themes/(.*)$ http://www.mydomain.com/themes/$2 [L]
RewriteRule http://(.*)/catalog/(.*)$ http://www.mydomain.com/$2 [L]
If I make the domain variable I get the pictue/image display problem again.
Do you have any suggestions?
thanks!
RewriteRule http://(.*)/catalog/(.*).html$ http://$1/product.php?article=$2
RewriteRule http://(.*)/catalog/images/(.*)$ http://$1/images/$2 [L]
RewriteRule http://(.*)/catalog/themes/(.*)$ http://$1/themes/$2 [L]
RewriteRule http://(.*)/catalog/(.*)$ http://$1/$2 [L]
If you're going to check for the subdomain, you should use something like this:
RewriteCond %{HTTP_HOST} !www\.mydomain\.com [NC]
RewriteRule ^catalog/(.*)\.html$ /product.php?article=$2 [L]
Welcome to WebmasterWorld [webmasterworld.com]!
closed is correct -- The domain (host name) is not "visible" to RewriteRule, and RewriteCond must be used to check the domain or to create backreferences based on the domain information.
Also, you have a choice between creating an external redirect and an internal filepath substitution with mod_rewrite; When applicable, an internal rewrite is much more efficient, saving an extra HTTP "handshake" with the client browser.
ref: [httpd.apache.org...]
Jim