I'm not a wizard with mod_rewrite, but shouldn't it be
RewriteRule ^/a\.htm$ /dir/b.htm
Welcome to WebmasterWorld!
If you are using mod_rewrite in .htaccess for per-directory rewrites, leave the leading slash off the path in the left side. If you are using mod_rewrite in httpd.conf, then include the slash in both sides.
This should work in a per-directory .htaccess environment:
RewriteRule ^a\.htm$ /dir/b.htm
You may also need to use RewriteBase if your filespath does not start in the same directory as your site's index page.
What happens when you try to test this? Are there any entries in your raw error log file?
tried it, still getting a 404
says it can't find dir/b.htm
any more thoughts? thanks
If it says it can't find yourdomain/dir/b.htm, the the rewrite is working but it can't find that subdirectory for some reason. Can you access yourdomain/dir/b.htm directly?
Your rewrite rule is correct, so something else is happening. If you have more rewrite rules ahead of or following the one we're talking about, you may want to add the [L]ast flag to some or all of your rules. Also, check the description of RewriteBase and make sure it does not apply to your case.
The webserver´s error message surely is a bit more precise. Looking at the absolute path that is probably given there will help you determine if you need to set the RewriteBase directive.
It is always helpful to post error messages. Something that might not look relevant to you might be just the thing that helps Jim know whats wrong. :)
It doesn't seem to be related to the subdirectory.
I put both files in the same directory and
RewriteRule ^a\.htm$ /b.htm
didn't work either.
The only msg I get is
The requested URL /b.htm was not found on this server.
I am doing is in a secure environment so the path is:
but the hosting company says it should work in the secure environment (modrewrite is working ok in std environ)
(hosting company is pair, so I tend to trust them)
Given a request GET /path/to/aaron.html
RewriteRule aaron.html jesse.html
will result in GET* /path/to/jesse.html while
RewriteRule aaron.html /jesse.html
will result in GET* /jesse.html.
If you want the directory prefix that got removed by mod_rewrite in .htaccess context prior to matching to be added after the rewrite is done your substitution may not start with a slash. If it does start with a slash this substitution is taken as an absolute path.
* Note that this will be an internal redirect unless you specify the R flag. So there is really no HTTP request using the GET method.
I tried this:
RewriteRule ^a\.htm$ b.htm
and got this error msg:
The requested URL /usr/home/myid/public_ssl/b.htm was not found on this server.
But b.htm is there
I wonder if symbolic links are causing problems?
/bin/pwd for public_ssl gives:
anyone got any ideas?
If you can access /usr/home/myid/public_ssl/b.htm via your server without any rewrite rules then you can rule out the symlink as the cause of error.
Is /usr/home/myid/public_ssl your DocumentRoot?
Can the user apache runs as access the file?
To check you could always su to the user apache is running as and check whether you can read it.
If you do cd /usr/home/myid/public_ssl pwd should display /usr/home/myid/public_ssl while doing cd /usr/www/users/myid/public_ssl pwd should display /usr/www/users/myid/public_ssl.
Check whether the symlink points to the right directory using ls -l.
Just some random ideas.
I suggest you investigate using the RewriteBase directive of mod_rewrite, as I posted in msg #3 above.
If you can't use RewriteBase to fix your problem, we are going to need more detail on what your paths look like, and what your environment is like. I think you are saying that you are trying to redirect from both http and https to a file in a subdirectory, and you are getting different results between http and https, but it's not clear.
Your problem requires attention to detail. Please describe exactly what your situation is as far as http/https, and the structure of your directories and paths from both views (if applicable).
I can now replicate the same prob in a non-secure environment, so I suspect it is independent of secure/nonsecure.
I can access a.htm & b.htm this way:
If I insert this:
RewriteRule ^a\.htm$ b.htm
gives one of these 2 error mssages (not always the same one)
404 page not found
/usr/home/myid/public_html/b.htm not found
but that is where it is
Jim & Andreas, thanks for all of your help!
Cool! Glad to hear it!