Forum Moderators: phranque
http://www.olddomain.com/googleverification.html RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com.com$
RewriteRule ^(.*)\.html$ http://www.newdomain.com/$1/ [L,R=301]
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif|png|pdf|tiff|bmp|ico|gz|zip|xml|txt)$
RewriteRule ^(.*)([^/])$ http://www.newdomain.com/$1$2/ [L,R=301]
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteRule ^(.*)([^/])$ http://www.newdomain.com/$1$2/ [L,R=301]
RewriteRule ^(.*[^/])$ http://www.newdomain.com/$1/ [L,R=301]
To match a URL that doesn't end with a slash?
^(.+[^/])/?$
Note that in this situation it doesn't need to be .* --assuming htaccess at the root-- because the server would never see a request consisting solely of a / slash. (Even if it's a malformed request like "http://example.com//" mod_rewrite probably won't see the extra slash.) RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteCond %{THE_REQUEST} !/googleverification\.html [NC]
RewriteRule ^ http://www.newdomain.com%{REQUEST_URI} [L,R=301,NE] RewriteCond {HTTP_HOST} !^www.newdomain.com$
RewriteCond %{REQUEST_URI} !^/googleverification.html
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
^(.+[^/])/?$
Note that in this situation it doesn't need to be .*
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
RewriteRule ^googleverification\.html - [END]
wouldn't that result in a match of at least 2 chars