Welcome to WebmasterWorld Guest from 126.96.36.199
but I really want to serve a page from a subdirectory
RewriteRule ^a\.htm$ /dir/b.htm
but I can't get it to work
I've read the documentation over & over & I can't figure out what to do
Can someone help me? Thanks!
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?
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.
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. :)
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)
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.
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 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