homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Help! .htaccess modification!
.htaccess mod_rewrite images pictures graphics
jakob77




msg:1503252
 9:23 am on Oct 22, 2003 (gmt 0)
My original .htaccess file is the following:

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!

 

jakob77




msg:1503253
 9:24 am on Oct 22, 2003 (gmt 0)
Sorry, the new version is of course:

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]

jakob77




msg:1503254
 9:25 am on Oct 22, 2003 (gmt 0)

do you have any suggestions?

thanks!

closed




msg:1503255
 1:51 pm on Oct 22, 2003 (gmt 0)

Welcome to WebmasterWorld.com [webmasterworld.com], jakob77!

If you're going to check for the subdomain, you should use something like this:

RewriteCond %{HTTP_HOST} !www\.mydomain\.com [NC]

Also, since you're just using the [L] tag, a more efficient way of doing things would be to remove the lookup to your domain in your substitution:

RewriteRule ^catalog/(.*)\.html$ /product.php?article=$2 [L]

I also added a backslash before .html so that you would match a dot, and not just any character.

jdMorgan




msg:1503256
 5:20 pm on Oct 22, 2003 (gmt 0)

jakob77,

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

jakob77




msg:1503257
 8:26 pm on Oct 22, 2003 (gmt 0)

Thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved