Web Hosting Talk







View Full Version : Apache question


sebasch
09-06-2005, 11:29 AM
Is there a way to tell apache to return an html document if not found the specified in the url ?..
(Returning OK 200 and not 404)

regards

ambirex
09-06-2005, 12:59 PM
mod_rewrite can do this, here is an example a .htaccess file that will redirect any page/directory not found to phpinfo.php without changing the URL:


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /php.php?file=$1 [L,QSA]
</IfModule>

sebasch
09-06-2005, 01:25 PM
thanks ambirex.

this go on the .htaccess file ?

I obtain 500 internal server error!..
what's wrong ?..

thanks again

ambirex
09-06-2005, 01:49 PM
sebasch,

Check your error log to see if that points to any problems. Here are a couple things you could do to check:

make sure you have mod_rewrite configured in your apache httpd.conf file:

ie:
LoadModule rewrite_module libexec/mod_rewrite.so
AddModule mod_rewrite.c

you could also try taking out the commands and leaving only:

<IfModule mod_rewrite.c>
RewriteEngine on
</IfModule>


to see if it can at lease activate the rewrite engine.

sebasch
09-06-2005, 01:55 PM
I'm reading, may be I need to add some lines on httpd.conf ?
the error log says :

.htaccess: RewriteEngine not allowed here

thanks!

sebasch
09-06-2005, 02:04 PM
Thank you for your help!..
It worked!..
I added "AllowOverride FileInfo" under <Directory>

regards