Forum Moderators: phranque
If someone goes to http://www.example.com, it will automatically redirect to http://www.example.com/myfolder/index.htm
Now, if a user removes the index.html from the url, so then the url would be http://www.example.com/myfolder/, the browser results in http 403 forbidden. Shouldn't the page used the DirectoryIndex from the virtual hosting? Here is my httpd.conf code. (I tried to move the DirectoryIndex down a few lines, but that didnt do anything). I'm just not so sure what I'm doing wrong. Everything else is working great.
<VirtualHost *>
ServerName www.example.com
#DirectoryIndex index.htm
DocumentRoot "/home/myapp"
ServerAlias example.com
DirectoryIndex index.htm
#Turn rewrite engine on
RewriteEngine On
RewriteRule ^/$ http://www.example.com/myapp/index.htm [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com$1 [R=301,L]
</VirtualHost>
[edited by: jdMorgan at 2:47 am (utc) on Aug. 25, 2007]
[edit reason] example.com [/edit]
So, you are getting a 403 because you are redirecting the requested URL example.com/ to the URL example.com/myapp/index.htm, then the server translates that requested URL to the filepath /home/myapp/home/myapp/index.htm, which does not exist.
Because you have probably not enabled Options Indexes, no default directory listings can be served when the index file is missing, so you get a 403.
In this case, you don't need either a redirect or a rewrite. If the DocumentRoot is /home/myapp, just put the index file there at /home/myapp/index.htm and it should work as-is.
In case it is not clear, a server typically translates URLs to filepaths like this:
So starting with example.com/, we remove the hostname, leaving only "/", then prefix that with the DocumentRoot, resulting in "/home/myapp/", and then we apply "DirectoryIndex index.htm" from mod_dir , and the final filepath for that requested URL is "/home/myapp/index.htm"
No redirect or rewrite is required.
Jim
It is very bad form for the root URL of a site to redirect to an internal page.
You would be much better off if that redirect were changed to a rewrite.
The user would continue to see the URL they requested, while the server would still fetch the content from that deep filepath.
This answer from last week is for almost the same question that you asked: [webmasterworld.com...]
Now, if a user removes the index.html from the url, so then the url would be http://www.example.com/myfolder/, the browser results in http 403 forbidden. Shouldn't the page used the DirectoryIndex from the virtual hosting? Here is my httpd.conf code. (I tried to move the DirectoryIndex down a few lines, but that didnt do anything). I'm just not so sure what I'm doing wrong. Everything else is working great.
I'd suggest you stop using FP to create web pages and either use another software that creates HTML extension names or change the setting in FP.
Some Webmasters do not have a choice as to their development tools, and must use whatever their employer dictates. That may or may not be the case here.
For the reasons above, and also to prevent confusion, I'd like to ask that we stay strictly on-topic in this forum until the original question or problem --as asked or described by the original poster-- is answered or solved. Discussion of secondary issues is then more than welcome.
Thanks,
Jim
<VirtualHost *>
ServerName www.example.com
#DirectoryIndex index.jsp
DocumentRoot "/usr/oracle/oraInventory/OraHome_1/j2ee/home/applications/example"
ServerAlias example.com
DirectoryIndex index.jsp
#Turn rewrite engine on
RewriteEngine On
RewriteRule ^/$ http://www.example.com/myapp/index.jsp [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com$1 [R=301,L]
</VirtualHost>