Forum Moderators: phranque

Message Too Old, No Replies

can I use wildcards in .htaccess files?

e.g. ewriteCond %{HTTP_HOST} ^*wildcard*\.com$ [NC]

         

GerBot

3:05 pm on Dec 28, 2004 (gmt 0)

10+ Year Member



I'm using the following code to redirect my domains from [mydomain.com...] to [mydomain.com...]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ [mydomain.com...] [R=301,L]

Is there a way I could use wild cards so that I could use the same htaccess file for all my domains rather than write a new file for each domain?

e.g.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^*wildcard*\.com$ [NC]
RewriteRule ^(.*)$ [*wildcard*.com...] [R=301,L]

thanks for your help

jdMorgan

3:17 pm on Dec 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, this is a simple application of regular expressions and mod_rewrite's back-reference capability. See the documents cited in our charter [webmasterworld.com] to get started.

Jim