In my directory
I have the following .htaccess
file:
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:49900/home [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49900/$1 [P,L]
It routes correctly if I provide a page (a node app with .eps files)
http://tanguay.info/webtech/home
But if I don't provide a page:
It gives this error:
Error: ENOENT: no such file or directory, open '/home/tanguay2/public_html/n49900_dpndev/systemPages/index.html.var.ejs'
It seems to be going to index.html.var.ejs
instead of the http://127.0.0.1:49900/home
that I specified, but I don't know where it is getting this index.html.var
information.
How do I get it to correctly link to http://tanguay.info:49900
if I provide no page?
index.html.var
maybe set as yourDirectoryIndex
. In which case, mod_dir issues an internal subrequest for this document. (Does this file exist?)How you match this with mod_rewrite can depend on your Apache version (2.2 vs 2.4). In Apache 2.2 mod_dir executes before mod_rewrite. The order reversed in 2.4.
In Apache 2.4 a
RewriteRule
pattern of^$
should be sufficient (since it is processed before mod_dir issues the subrequest). If the directory index document does not exist then this should also work on Apache 2.2. However, to catch both possibilities then check for both...For example, change your first
RewriteRule
to read:Or, you could disable the
DirectoryIndex
(if it's not being used) at the top of your.htaccess
file: