Page 1 of 1
.htaccess Question Regarding Subdirs
Posted: Sun Dec 28, 2008 3:05 pm
by volomike
On my shared hosting plan, I have my site as mysite.com. But on my local Ubuntu workstation, I have my site as /var/www/mysite.com. Thus, if I want to do this in my .htaccess file for a Front Controller...
ErrorDocument 404 /mysite.com/front.php
...note that this works locally, but not on the shared hosting plan. My question is simple -- what's the trick where I can dynamically make that ErrorDocument statement work both on the shared hosting plan and my local Ubuntu workstation, such as use an .htaccess kind of variable or something?
Re: .htaccess Question Regarding Subdirs
Posted: Sun Dec 28, 2008 3:55 pm
by volomike
I tried all manner of:
Code: Select all
<Directory />
ErrorDocument ...blah blah...
</Directory>
<Directory /mysite.com>
ErrorDocument ...blah blah...
</Directory>
...and even tried Location directives, but this didn't work on my shared hosting provider for some reason.
In the end I had to poke around in my /etc/apache2/mods-available and /etc/apache2/mods-enabled directories locally on my workstation at home and do experimentation to find modules that were on my remote host but were not on my host. Thus, I ended up with the following solution that works at least for me. You may wish to replace "expires_module" with some other kind of "something_module" in your situation.
Code: Select all
<IfModule expires_module>
ErrorDocument 404 /front.php
</IfModule>
<IfModule !expires_module>
ErrorDocument 404 /mysite.com/front.php
</IfModule>
Re: .htaccess Question Regarding Subdirs
Posted: Sun Dec 28, 2008 6:48 pm
by alex.barylski
If my previous answer doesn't give you what you need, you might try the Linux forum and VladSun will likely answer you in more detail, he's helped me several times in with everything Linux.
You shared hosting account, I'm wondering if it has ErrorDocument disabled...I would try that rewrite rule I supplied and see if that works.