I'm getting problems getring an easy redirect statement to consider impact on my Godaddy account. I've the next claims during my .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.mydomain.net$ [NC]
RewriteRule ^(.*)$ http://mydomain.net/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC]
RewriteRule ^/lists/$ / [R=301]

RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC]
RewriteRule ^/blog/$ http://myotherdomain.net/ [R=301]

The first redirect ALWAYS work. The second and 3rd ones however, NEVER work. I simply obtain a 404 in the server. The Apache logs don't reveal any helpful infomation - only a 404.

Any ideas, anybody? Your assistance will be greatly appreciated. Thanks

Per-directory Rewrites
While using the rewrite engine in .htaccess files the per-directory prefix (which always is identical for any specific directory) is instantly removed for that pattern matching and instantly added following the substitution continues to be done.

So just leave the key slash from the pattern.

Simply take away the slashs at the start. Additionally, it may be helpful to create the slashs in the finish optional.

RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC]
RewriteRule ^lists/{0,1}$ / [R=301]

RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC]
RewriteRule ^blog/{0,1}$ http://myotherdomain.net/ [R=301]

For straightforward redirects like this, better make use of the simple RedirectMatch directives:

RedirectMatch 301 ^/lists/$ http://mydomain.net/
RedirectMatch 301 ^/blog/$ http://myotherdomain.net/

Should you insist upon using spinning make certain you add the L flag for your rules.

Apache mod_rewrite Flags states :

You'll more often than not desire to use [R] along with [L] (that's, use [R,L]) because by itself, the [R] flag prepends http://thishost[:thisport] towards the URI, however passes this onto the following rule within the ruleset, which could frequently lead to 'Invalid URI in request' alerts.

Put the first last. Once it encounters a redirect match, it runs it and ignores the relaxation.