Mordent 0 Report post Posted May 18, 2009 Hi all!It's been a while since I've posted on Xisto, but as always when a technical problem comes up this is the first place I turn to for answers. So, on to my issue:I'm running Fedora Core 10 (64-bit) on my machine, with the classic Apache/MySQL/PHP package build. I'll admit that I needed a little help from this site to get it working well (though note that I didn't do the firewall malarky on there, as I found a nicer way of getting it to work that currently eludes me as to how I found it), but it's generally working absolutely fine.The one issue I have is in using .htaccess. Assuming an entirely default setup for Apache (I can quote relevant sections of phpinfo if needed), is it just my understanding of how .htaccess works that's flawed, or something else entirely?I'm trying to perform some simple error handling (404, 500, etc.) using a .htaccess file in the root directory of the website in question (/var/www/html/mywebsite/) as below: ErrorDocument 403 /index.php?page=forbiddenErrorDocument 404 /index.php?page=not_foundErrorDocument 500 /index.php?page=server_errorGiven that I'm performing the relevant checks in the index.php page (i.e. using $_GET) is there any reason why I can't use this approach? If not, why is it that when I type "localhost/mywebsite/test.html" in to my web browser (and yes, clearly Apache is running, though I have made that mistake before ) I get the standard error?Not FoundThe requested URL /mywebsite/test.html was not found on this server.Any help or pointers towards pages that might be helpful would be appreciated, as I can't see any reason for it not to be working. Thanks in advance! Share this post Link to post Share on other sites
yordan 10 Report post Posted May 18, 2009 Did you first check that, with a standard index.html file in (/var/www/html/mywebsite/index.html) you see something when you point your browser to "localhost/mywebsite/" ? Share this post Link to post Share on other sites
Mordent 0 Report post Posted May 19, 2009 (edited) Yup. As I said, the rest of the website's working absolutely fine. It prints HTML, parses PHP, accesses the MySQL database etc. with no problems, I just can't seem to get .htaccess to work. Odd, huh? EDIT: So, after trawling cyberspace for the answer, I found it (or at least the start to it). Seems the default installation for Apache doesn't allow overrides. One tweak of that later and .htaccess works like a charm...that is when SELinux is disabled. Damn, I hate that thing...I don't suppose anyone knows a way to stop SELinux from blocking Apache from using the .htaccess files, or perhaps some other workaround? EDIT: After some more rummaging around, I've drawn a blank. I'm tempted just to disable SELinux, as it's being more of a pain than anything, but as a last attempt to get something working I figure I might as well show you the errors I'm getting: Summary SELinux is preventing the httpd from using potentially mislabeled files (./.htaccess). Detailed Description SELinux has denied httpd access to potentially mislabeled file(s) (./.htaccess). This means that SELinux will not allow httpd to use these files. It is common for users to edit files in their home directory or tmp directories and then move (mv) them to system directories. The problem is that the files end up with the wrong file context which confined applications are not allowed to access. Allowing Access If you want httpd to access this files, you need to relabel them using restorecon -v './.htaccess'. You might want to relabel the entire directory using restorecon -R -v '.'. Additional Information Source Context:Â Â system_u:system_r:httpd_t:s0 Target Context:Â Â unconfined_u:object_r:user_home_t:s0 Target Objects:Â Â ./.htaccess [ file ] Source:Â Â httpd Source Path:Â Â /usr/sbin/httpd Port:Â Â <Unknown> Host:Â Â steve Source RPM Packages:Â Â httpd-2.2.11-2.fc10 Target RPM Packages:Â Â Policy RPM:Â Â selinux-policy-3.5.13-59.fc10 Selinux Enabled:Â Â True Policy Type:Â Â targeted MLS Enabled:Â Â True Enforcing Mode:Â Â Enforcing Plugin Name:Â Â home_tmp_bad_labels Host Name:Â Â steve Platform:Â Â Linux steve 2.6.27.21-170.2.56.fc10.x86_64 #1 SMP Mon Mar 23 23:08:10 EDT 2009 x86_64 x86_64 Alert Count:Â Â 9 First Seen:Â Â Thu 21 May 2009 16:19:04 BST Last Seen:Â Â Thu 21 May 2009 16:44:42 BST Local ID:Â Â d2abe2b4-5b42-485d-81c6-d3e9578d91a1 EDIT: And, as per usual, I've been a complete dunce. I did what it told me to do, and it now works like a charm! Edited May 21, 2009 by Mordent (see edit history) Share this post Link to post Share on other sites