XAMPP/Apache - '.htaccess' Files & Error 500

Problems with the Windows version of XAMPP, questions, comments, and anything related.

XAMPP/Apache - '.htaccess' Files & Error 500

Postby Pryath » 04. October 2013 17:37

I am using XAMPP 1.8.3 (latest version with PHP 5)
I'm running Windows 7 64-bit. I have UAC fully enabled & 'XAMPP Control Panel' is set to always 'Run As Administrator'.
I have a firewall but am certain that it is not causing my problems (no connection requests are popping up and the apache/mysql processes are NOT being blocked).

XAMPP works properly under normal conditions & I've been using it for a while (I always do clean installs with updates).
In the XAMPP security section, I have set a 'root' password AND a username/password to protect the XMAPP directory.

I have been having a problems trying to get apache to use an '.htaccess' within the directory of a website.
The error I'm getting is "Error 500".
If I erase everything from the '.htaccess' file within the WEBSITE'S directory (not the one in 'C:/XAMPP/htdocs/xampp/', but the one in 'C:/XAMPP/htdocs/xampp/website/' directory), the index page will load.
If I add ANYTHING (even something like 'RewriteEngine On'), it will once again display 'Error 500'.

I went to my 'C:\XAMPP\apache\conf\httpd.conf' file and made sure to change 'AllowOverride' from 'None' to 'All' & restarted Apache but that did not help. Beyond that, this 'httpd.conf' file has default settings (from XAMPP installation).

In my 'C:\XAMPP\htdocs\xampp\' directory is a '.htaccess' file with the following:
Code: Select all
AuthName "xampp user"
AuthType Basic
AuthUserFile 'C:\XAMPP\security\xampp.users'
require valid-user

I tried adding this to the '.htaccess' file inside 'C:\XAMPP\htdocs\xampp\website', but it once again gave me an error (even when this code was the only code in the file).

I also tried setting up a virtual host as per these instructions: http://sawmac.com/xampp/virtualhosts/
I could not get the virtual host to work either, kept getting "Object Not Found", so I do not know if it would have fixed the '.htaccess' problem or not.

Here are the 3 different versions of '.htaccess' that I've tried to use. All of them cause "Error 500".
Version 1:
Code: Select all
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^(.*)$ /profile.php/$1 [QSA,L]


Version 2:
Code: Select all
RewriteEngine On
RewriteCond? %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ /profile/profile.php?username=$1


Version 3:
Code: Select all
# 1 Establish a custom 404 File not Found page
ErrorDocument 404 /404.php
# 2 Prevent directory file listing in all of your folders
IndexIgnore *
# 3 Make pages render without their extension
Options +MultiViews


Problem is really giving me a headache. Hope giving this information will help you to help me. Thanks for reading.
Last edited by Pryath on 04. October 2013 17:46, edited 1 time in total.
Pryath
 
Posts: 5
Joined: 15. December 2012 16:06
XAMPP Version: 5.5.19
Operating System: Windows 7 64-bit

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Altrea » 04. October 2013 17:45

contents of your \xampp\apache\logs\error.log and \xampp\php\logs\php_error_log?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6946
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Pryath » 04. October 2013 17:53

Altrea wrote:contents of your \xampp\apache\logs\error.log and \xampp\php\logs\php_error_log?

Ah looks like I'm getting this in my '\xampp\apache\logs\error.log'
Code: Select all
[Thu Oct 03 17:34:11.911372 2013] [core:alert] [pid 4992:tid 1644] [client ::1:7325] C:/XAMPP/htdocs/xampp/website/.htaccess: RewriteEngine not allowed here


I looked at the php log and found nothing significant/related to this problem.

How do I prevent it from giving me this 'RewriteEngine not allowed' error?
Pryath
 
Posts: 5
Joined: 15. December 2012 16:06
XAMPP Version: 5.5.19
Operating System: Windows 7 64-bit

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Altrea » 04. October 2013 18:00

At this point it can only have two possible issues:
modules\mod_rewrite is not Loaded
AllowOverride is not correctly set.

have you restarted Apache after changing the AllowOverride value?
And where excectly in your httpd.conf have you changed it from None to All?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6946
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Pryath » 04. October 2013 18:09

Altrea wrote:At this point it can only have two possible issues:
modules\mod_rewrite is not Loaded
AllowOverride is not correctly set.

have you restarted Apache after changing the AllowOverride value?
And where excectly in your httpd.conf have you changed it from None to All?


In 'C:\XAMPP\apache\conf\httpd.conf'
Code: Select all
<Directory />
    AllowOverride None
   Require all denied
</Directory>


However, since that did not work I CHANGED IT BACK TO 'None' for that entry (because I don't want security problems if such a thing can be caused by this), searched for more "AllowOverride" entries and figured out I had to MANUALLY add the following entry:
Code: Select all
<Directory "C:/XAMPP/htdocs/xampp/website">
    AllowOverride All
    Options None
    Require all granted
</Directory>

After that I restarted Apache & MySQL

It stopped 'Error 500'

However, now I'm getting "Error 403"
Code: Select all
Access forbidden!

New XAMPP security concept:

Access to the requested object is only available from the local network.

This setting can be configured in the file "httpd-xampp.conf".


It appears as though I'll have to set another '<Directory "C:/XAMPP/htdocs/xampp/website">' entry here (in 'C:\XAMPP\apache\conf\extra\httpd-xampp.conf').
Should I just paste a copy of the one I used in the other file, or is there a more secure version of that?

Edit: I found this entry inside of 'C:\XAMPP\apache\conf\extra\httpd-xampp.conf'

Code: Select all
<Directory "C:/XAMPP/htdocs/xampp">
    <IfModule php5_module>
       <Files "status.php">
          php_admin_flag safe_mode off
       </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>


Is it 'AllowOverride AuthConfig' that's causing problems?
Last edited by Pryath on 04. October 2013 18:15, edited 1 time in total.
Pryath
 
Posts: 5
Joined: 15. December 2012 16:06
XAMPP Version: 5.5.19
Operating System: Windows 7 64-bit

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Altrea » 04. October 2013 18:15

Simply not create your own project folders inside \xampp\htdocs\xampp\ but directly in \xampp\htdocs\
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6946
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Re: XAMPP/Apache - '.htaccess' Files & Error 500

Postby Pryath » 04. October 2013 18:16

Altrea wrote:Simply not create your own project folders inside \xampp\htdocs\xampp\ but directly in \xampp\htdocs\


Just moved my directory to
'C:\XAMPP\htdocs\website'

The pages are loading successfully with the following .htaccess in the directory
Code: Select all
#XAMPP Security
AuthName "xampp user"
AuthType Basic
AuthUserFile "C:\XAMPP\security\xampp.users"
require valid-user

RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
# Custom "404 File not Found" page
ErrorDocument 404 /website/404.php
# Prevent directory file listing in all of your folders
IndexIgnore *
# Make pages render without their extension
Options +MultiViews


They work without the XAMPP Security parts, but I figured it'd be a good idea to keep them in.
I removed the entry I made in 'C:\XAMPP\apache\conf\httpd.conf' as it was no longer valid anyways.
The '.htaccess' file is working. Thanks for the help.

If there are any additional measures I should take for security reasons please let me know.
Pryath
 
Posts: 5
Joined: 15. December 2012 16:06
XAMPP Version: 5.5.19
Operating System: Windows 7 64-bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 47 guests