Jump to content

.htaccess issue in XAMPP


xProteuSx

Recommended Posts

I have XAMPP set up on my machine, and I currently have two projects that I am working on in my 'htdocs' directory.  One is in '\htdocs\project1' and the other is in '\htdocs\project2'.  Both projects use a .htaccess file to allow PHP parsing in a .HTML file.  The same one-line .htaccess file exists in the root directory of both projects.  The line is:

 

AddHandler application/x-httpd-php5 .html .php .htm .shtml

 

This .htaccess file works in the '\htdocs\project1' folder, but does not work in the '\htdocs\project2' folder.  That is to say, project1 .HTML files are parsed for PHP.  However, in project2 the PHP code appears as text instead of being parsed as PHP.

 

What is going on?  I went through a lot of trouble to get the .htaccess file to work for project1, back when that was my sole project.  Now it looks like I am back to the drawing board for project2.  How infuriating!

 

Any ideas?

Link to comment
Share on other sites

Yeah, I've restarted, reinstalled, rebooted.  I've taken project 2 out altogether, and put project 1 straight into the \htdocs\ folder, as in \htdocs\index.html and still nothing.

 

However, I've tested a few things out:

 

This is my .htaccess file:

 

AddHandler application/x-httpd-php5 .html .php .htm .shtml

ErrorDocument 400 /400.html

ErrorDocument 401 /401.html

ErrorDocument 403 /403.html

ErrorDocument 404 /404.html

ErrorDocument 500 /500.html

 

The ErrorDocument lines work.  So if I type in a non-existent page, such as adasdfasdf.html, it does take me to the /404.html page, as stated in the .htaccess file, so it looks like it is reading and implementing some of the settings there. So now I'm thinking that the following line is not working:

 

AddHandler application/x-httpd-php5 .html .php .htm .shtml

 

Its ALWAYS worked before, so now I don't know what is happening.

Link to comment
Share on other sites

I've figured it out.  The .htaccess file was being read, as I discovered.  For some reason the following line, which always worked for me, didn't work anymore:

 

AddHandler application/x-httpd-php5 .html .php .htm .shtml

 

I found a replacement, which appears to be universally functional:

 

<FilesMatch "\.(htm|html|php)$">

SetHandler application/x-httpd-php

</FilesMatch>

 

When I put this nonsense into the .htaccess file, all was well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.