PHP Configuration Setting for 404 Errors - php

Our PHP installation is intercepting 404 Page Not Found errors and displaying this basic and generic 404 error message on pages with the .php extension:
File not found.
It is preventing the requestor from seeing our nicely formatted ERROR 404 Page.
How do I shut off the PHP setting to have the server use our Apache directives for 404's?
Here is a screenshot of the nicely formatted 404.
Here is a screenshot of the 404 that does not the follow Apache Directives.

Check your .htaccess file. Check if custom ErrorDocument is set. For example:
ErrorDocument 404 /file-not-found.php
In addition check if there any redirects matching pages having .php extension. For example:
RewriteCond %{THE_REQUEST} \ /+[^\?]+\.php
RewriteRule ^ - [L,R=404]

I would start looking at the apache conf files (all the conf files in the apache folder i.e. in /etc/apache2 as example, or all the vhost files configuration that should be in something like /etc/apache2/sites-enabled or similar)
if nothing is helping there then
I would start from having a look at the .htaccess files
as I remember there is nothing in the php configuration that is telling to intercept the 404

Due to enabling the mod_proxy_fcgi and using PHP-FPM this might happen.The default error page in the proxy is File not Found. Try adding the following in your http.conf or apache.conf
ProxyErrorOverride On

Related

Why does this Rewrite rule throws a 500 inside .htaccess file?

on a server with PHP and mod_rewrite I have the following .htaccess in the document root:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .(rewriteme)$ rewrite.php [L]
</IfModule>
When I make a request to http://theserver.com/arewriteme, I get a 500 internal server error.
But on my local system, the rule above works great and the script rewrite.php is executed (it simply echoes It works!) when I request http://localhost/arewriteme:
<?php echo "It works!"; ?>
Why do I get a 500 error on the remote server though? I don't have access to the global Apache configuration, but I am sure the module gets loaded as `phpinfo() shows:
I looked at different questions here on SO, but basically all say that it the error is due a syntax error within .htaccess (which is not my case because the rule works on localhost).
So, maybe, there's something in the global configuration of Apache? Maybe the creation of .htaccess is somehow denied? Could it be possible?
Thanks for the attention.
EDIT: I was able to contact the hosting provider and they told me that they disabled .htaccess throught the whole htdocs directory. How did they do that so that the server thrown a 500 Internal Server Error? AllowOverride None inside the main Apache won't do the job because in this case Apache would simply ignore the rules inside the .htaccess but won't throw any error...

Strange issue with .htaccess file unable to remove PHP extensions

I am on a VPS running Ubuntu 14.04 x64, and I have enabled mod_rewrite.
This works (i.e. correctly redirects to testfile.php):
RewriteRule ^othername$ testfile.php
But this doesn't (gives me a 404 error, saying "The requested URL /testfile was not found on this server"):
RewriteRule ^testfile$ testfile.php
So I essentially cannot redirect a URL to a file of the same name but with a PHP extension. The two examples are both working locally with MAMP.
What could be causing this issue?
As anubhava said, you just have to add Options -MultiViews at the top of your .htaccess.

mod_rewrite not working - results in 404 error and no logs

I’m running localhost XAMPP on my Mac and trying to setup the Apache server with mod_rewrite, here’s my code in .htaccess (which is in htdocs)
<IfModule mod_rewrite.c>
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^test/?$ api/rest/v1.0/api_controller.php?request=$1 [NOCASE,LAST] # Handle requests for “test"
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
</IfModule>
This is the only code in the .htaccess file too.
When I try my link http://localhost/test/1 in my browser, I just get directed to a 404 error.
I’ve checked under htdocs/logs/rewritelog but there aren’t any files nor even a folder called logs.
UPDATE
I’m running Apache version 2.4.10
So it turns out the .htaccess file was saved as .htaccess.txt where the .txt extension was hidden. If you get the same error, check the file in Get Info.

500 Internal Server Error with Wamp server

I've created a web service using php, slim and mysql but when I try to access the urls it gives me "The server encountered an internal error or misconfiguration and was unable to complete your request."
When I check the log it gives me :
C:/wamp/www/task_manager/.htaccess: Invalid command '.htaccess', perhaps misspelled or defined by a module not included in the server configuration
I checked few things online and I can ensure you that rewrite_module is installed and activated (not commented in the http.config
does anyone know how to fix that?
I ll attach the content of my .htaccess
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
Remove the line .htaccess from your .htaccess file.
if you install new wamp on your system,
and you are using htaccess in your project to rewrite some urls first you need:
Click on wamp icon and Go to "Apache" Then Click on "Apache Modules"
and make sure your RE WRITE extension should be checked.

.htaccess ErrorDocument Redirect

I am very new to Apache and .htaccess, and I had a simple question regarding how to handle 403 and 404 errors with Apache's ErrorDocument command.
Let's look at this code from an early CMS I wrote:
ErrorDocument 404 /admin/includes/access_deny.php?error=404
This will silently redirect the user to http://www.mysite.com/admin/includes/access_deny.php?error=404 when they get a 404 error.
Here is my problem, this error document will always be in the same place, with regards to the .htaccess file. However, if I need to move my installation, say to the directory subfolder, I will need to open the .htaccess file an update the to following, for it to work correctly:
ErrorDocument 404 /subfolder/admin/includes/access_deny.php?error=404
Is there a way I can have .htaccess redirect to this page admin/includes/access_deny.php?error=404 in regards to the file itself, not an absolute URL? Also, no matter where I would move the installation in the future, Apache will catch all 404 errors that are on the same level or sub-directories to this file.
Please let me know if that is not clear.
Thank you for your time.
From the manual:
URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser.
This thread may help you fix it though.

Categories