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...
Related
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
I have uploaded my laravel files to a Godaddy shared hosting.
My folder structure is like so
/mediservices
all-other-laravel-files-and-folders
/public_html
public
index.php
The content of the index.php in the public folder in public_html has been edited to point to the medsirvices folder like so -
22. require __DIR__.'/../../mediservices/bootstrap/autoload.php';
34. $app = require_once __DIR__.'/../../mediservices/bootstrap/app.php';
I have added the following to the .htaccess file in the public_html folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^mediservices
RewriteRule ^(.*)$ mediservices/$1 [L]
</IfModule>
I still get a 500 Internal Server Error when i go to the domain.
The full message is
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at webmaster#medcommhospital.com to
inform them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying
to use an ErrorDocument to handle the request.
Following the comments I can suggest the following. You need to make it clear if you want to serve the site under the domain root or under a folder on a domain.
Keep an eye on your logs, they tell you what the issue is. And make sure it actually is the same error, even a small change in details can give you more information.
Serve site under domain root
If you want to server your site/Laravel project under the domain root so on example.org/ it should be configured like the following.
# Contains all other laravel files
mediservices/
...
public_html/ <webserver root> <laravel public dir>
index.php
.htaccess
Your reference to your bootstrap in index.php should be.
__DIR__ . '/../mediservices/bootstrap/autoload.php'
Your .htaccess file should not need rewrite rules, so you can likely remove that configuration.
Serve site under folder on domain
However if you wish to serve your project from the folder mediservices/ after the domain part in the URL, so like example.org/mediservices/, and redirect users to that folder, you can keep the .htaccess rewrite rules you have, but you'll have to move your Laravel public folder to the following:
# Contains all other laravel files
mediservices/
...
public_html/ <webserver root>
mediservices/ <laravel public dir>
index.php
.htaccess <should stay under the public_html/ folder>
The references you use in index.php should be as you had, which is the following.
__DIR__ . '/../../mediservices/bootstrap/autoload.php'
i was trying to rewrite my post url with htaccess file when i put it into my project directory with following code in the htaccess file 500 internal error comes up, but when i left it(htaccess) blank without any code the page loads perfectly.
RewriteEngine on
RewriteRule ^post post.php
Error is:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at admin#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
what might be the issue, is there any permission need to be granted or any directives need to be on in config file or php.ini i am new in php development. plz help.
Thank you
It must be
RewriteEngine on
RewriteRule ^post$ post.php
try:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^post post.php [L,R=301]
</IfModule>
With this code the error should disappear but it's possible that your rule is not applying correctly, in this case we will fix
On my local development machine, I downloaded PDT + Zend Server, which included Apache 2.2.16 and PHP 5.3.5, running on Windows 7. On my local site, I included a .htaccess that includes ErrorDocuments for 404, 403, and 500. In my PHP, I use header("Http/1.0 404 Not Found") when the user requests a document that doesn't exist. On my local server, everything works great. My custom ErrorDocument appears and I'm happy.
I upload the everything to my shared host running Apache 2.2.38 and PHP 5.3.8 on a Linux server, and suddenly the ErrorDocuments only work if they don't come from PHP.
Is there some setting in PHP.ini or httpd.conf or .htaccess that allows Apace to see the error codes from PHP, which makes my dev server work correctly, but not my shared host?
In researching this, all I ever saw was "Apache doesn't see the status code once it passes off to PHP." In such a case, why does my dev server work right?
Edit
For clarity, here's the .htaccess:
# Use PHP 5.3
Action application/x-hg-php53 /cgi-sys/php53
AddHandler application/x-hg-php53 .php
#Deny Include Files
<Files *.inc>
order deny,allow
deny from all
</files>
#Provide custom error documents
ErrorDocument 404 /Errors/Http404.php
ErrorDocument 403 /Errors/Http403.php
ErrorDocument 500 /Errors/Http500.php
The .htaccess works because if the user navigates to myhost.com/jdkslfjdls the user receives the content of Errors/Http404.php.
However, if the user navigates to myhost.com/images/GetImage.php?Id=5 (when there is no image #5) the user receives no content.
If they navigate to (Internal IP Address)/images/GetImage.php?Id=5, the user receives the content of Errors/Http404.php.
A similar problem occurs if the user tries to access GetImage.php?Id=6 (when there is an image #6 but they don't have permission). On the shared server, they get a blank page or the browser's 403 error. On my dev server, they get my actual custom 403 error page.
Again, 403 error document works on the shared server if I try to access a .inc file.
Are you sure that your .htaccess file is used on the server? Sometimes the hosting company does not allow the global apache settings to be overwritten by the local .htaccess files.
If you however have access to your virtualhost configuration than you may want to look at the following directive
AllowOverride All
If instead you find
AllowOverride None
try to change as above.
Check if you have
AllowOverride ALL
in your apache.conf under the Directory directive inside the VirtualHost corresponding to your website
Anyway, that may be one possible cause, the other may be to check whether or not you have enabled mod_rewrite
On ubuntu or debian based systems, you'd simply link or copy the mod_rewrite.load from /etc/apache2/mods-available/mod_rewrite.load to /etc/apache2/mods-enabled/mod_rewrite.load
Rewrite should have nothing to do though, but I've seen cases where your .htaccess directives may require mod_rewrite
So check for those things in apache conf files.
If nothing happens contact me # phpcip#gmail.com
Hope it works.
I am getting a Internal Server Error when i use my htaccess file on a sub domain but it works fine with standard domains. I dont really understand how the htaccess file works totally so any help would be greatly aprricated.
.htaccess file
RewriteEngine on
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
Internal Server Error
The server encountered an internal
error or misconfiguration and was
unable to complete your request.
Please contact the server
administrator,
webmaster#-----.com
and inform them of the time the error
occurred, and anything you might have
done that may have caused the error.
More information about this error may
be available in the server error log.
Additionally, a 500 Internal Server
Error error was encountered while
trying to use an ErrorDocument to
handle the request.
When using RewriteRules, always, always use the conditions associated with the involved module. In case the module is not available, rewrites won't work (and your website will probably be broken because it relies on rewrite rules ;-)) but you won't get a 500 error:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
</IfModule>
If you don't get a 500 error after this, then the rewrite module is not loaded in your subdomain.
If you still get it, it's probably a redirect loop.
This is a punt - may be well off base.
Is your subdomain is based in a folder within the standard webroot?
ie subdomain.server.com is rooted in a folder subdomain within the webroot folder for server.com. So the webroot is something like /httpdocs/ and the subdomain is /httpdocs/subdomain/.
You may just need to define the RewriteBase as that folder
RewriteEngine on
RewriteBase /subdomain/
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
Does that help?