Forum Moderators: phranque
And then to use the following .htaccess
[code]
Options Indexes FollowSymLinks Includes ExecCGI
AddType text/x-server-parsed-html .html
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Rewrite Rule for domain-name.net
RewriteCond %{HTTP_HOST} <www.domain.com>
RewriteRule ^(.*)$ [newdomain.com...] [R=301, L]
[\code]
so I did this and got an error - checked the error log and saw
[code]
[Wed Aug 20 11:04:50 2003] [notice] Accept mutex: flock (Default: flock)
Ouch! malloc failed in malloc_block()
Ouch! malloc failed in malloc_block()
... repeats a bunch of times ...
[Wed Aug 20 11:10:44 2003] [alert] [client xxx.xx.xxx.xxx] /usr/local/etc/httpd/htdocs/.htaccess: RewriteRule: bad flag delimiters
[\code]
I'm assuming the bad flag delimiters are in the rewrite condition - but have NO experience with this.
Also, since I usually DON'T use the www.domain.com - do I need two conditions one with www.domain.com and one with just domain.com?
all help appreciated.
thanks
Max
RewriteRule ^(.*)$ http://newdomain.com [R=301, L]
to:
RewriteRule .* http://newdomain.com [R=301,L]
I removed the caret and dollar sign since they were redundant, and removed the space after the comma because the comma is the delimiter in the list.
You'll have to put your own domain name in the first line, and leave all the "weird" characters in place:
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Ref: Introduction to mod_rewrite [webmasterworld.com]
You can also get rid of the "Options +FollowSymLinks" line, because SymLinks are already enabled three lines above that in the preceding "Options" line.
The malloc problem is likely related to http.conf, and not to .htaccess. I'm no httpd.conf expert, though; hopefully someone else can help with that.
Jim
Can I use the exmple show for several paths
such as
[code]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com\aboutUs\.html [NC]
RewriteRule ^(.*)$ [newdomain.com...] [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com\companies\.html [NC]
RewriteRule ^(.*)$ [newdomain.com...] [R=301,L]
[\code]
and so on so that only the .html files are redirected?
or a rule that everything except domain.com/imanager/ gets redirected to newdomain.com
Sorry to be so block-headed.
thanks
Max
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
RewriteCond %{REQUEST_URI} .*\.html$
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
If the host is yourdomain.com and the file name ends with .html, apply the rule.
Or you could try this:
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
RewriteCond %{REQUEST_URI}!^/imanager/
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
If the host is yourdomain.com and the requested URI begins with /imanager/, apply the rule.
Of course, I'm still a newbie, so it may not be entirely right.
You can shorten that up a bit, since, by definition, RewriteRule examines a derivative of {REQUEST_URI}:
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
RewriteRule ^(.*)\.html$ http://newdomain.com/$1.html [R=301,L]
Jim