Forum Moderators: phranque
The problem?
I'd like to redirect any request for [domain1.com...] to [domain1.com....]
Normally I'd set up an htaccess file as follows:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain1\.com
RewriteRule (.*) [domain1.com...] [R=301,L]
But - if I'd do this in this case, any request for [domain2.com...] pages will redirect to [domain1.com...] ...
So - any idea what I need to change in my htaccess file so only requests for domain1 will redirect, and not requests for domain2?
Thanks,
Boaz
To avoid your current problem, simply change the RewriteCond pattern to a positive match for the domain that you *do* wish to redirect, making it "^domain1\.com" instead of "!^www\.domain1\.com".
See the mod_rewrite and regular expressions documentation cited in our forum charter.
Jim
i have a question about htaccess file
i'm using Pmachine CMS, on which u can view the same article using different files
for example
domain.com/more.php?id=503_0_3_0_M
and
domain.com/stuff.php?id=503_0_3_0_M
i did 4 months ago modrewrite and now my files have this look
domain.com/more/503_0_3_0_M/
domain.com/stuff/503_0_3_0_M/
503 (is article number)
3 (weblog number)
------
avoiding duplicate content, now i need to redirect all users who come with stuff/***_0_*_0_M/ to more/***_0_*_0_M/
need advice how to do it?
i try such a code, but it seems don't work
RewriteEngine OnRewriteRule /stuff/([A-Za-z0-9_]+)/ /more/$1/ [R=301]
what i'm doing wrong.
thx
In .htaccess, you'll need:
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^stuff/([A-Za-z0-9_]+)/$ /more/$1/ [R=301,L]
Jim
You might be able to combine several or many of your rewrites and redirects into just a few by making better use of mod_rewrite's regular-expressions-based pattern-matching and back-referencing capability.
Jim