Page 1 of 2

.htaccess are not working

PostPosted: 18. October 2006 05:02
by GetFree
WinXP SP2
Apache/2.2.0 (Win32)


The htaccess file in my public_html is not working.
-------------------------------------------------------
ServerSignature Off
DefaultType application/x-httpd-php

php_flag expose_php off

RedirectMatch 404 \.php$
--------------------------------------------------------

on httpd.conf I put:
AllowOverride All


Any idea what would be the problem???

thanks in advance.

PostPosted: 18. October 2006 05:07
by Izzy
Any clues in your apache error log?

PostPosted: 18. October 2006 06:39
by GetFree
No, nothing.

It's like the .htaccess file doesn't existe at all.

PostPosted: 18. October 2006 07:03
by Izzy
ServerSignature Off
won't work on custom error pages which is what you have in the default XAMPP installation.

This from \extra\httpd-default.conf
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature On


The error messages are contained within xampp\apache\error directory and are in various languages.

You can turn custom error messages off in the httpd.conf file by commenting out this line:
# Multi-language error messages
Include conf/extra/httpd-multilang-errordoc.conf

To:
# Multi-language error messages
# Include conf/extra/httpd-multilang-errordoc.conf

or comment out the entries in the conf file it refers to.

You should now be able to control the Apache default error messages using your .htaccess file although I have not tested your .htaccess file to see if it all works.

PostPosted: 18. October 2006 21:41
by GetFree
I deleted everything and I left just this line:

RedirectMatch 404 \.php$


which means any request for a php file should get a 404 responce.

but it doesn't work at all.

I dont know what's happening. The error log doesn't show anything unusual.

PostPosted: 19. October 2006 01:19
by Izzy
GetFree wrote:I deleted everything and I left just this line:

RedirectMatch 404 \.php$


which means any request for a php file should get a 404 responce.

but it doesn't work at all.

I dont know what's happening. The error log doesn't show anything unusual.

Thats really strange as it works for me when I put the above in a .htaccess file in my htdocs directory. I get an error message as expected. I also tried it in all of my vhosts domain's root directories with success in all cases.
The path to my vhosts is xampp\home\[username]\public_html

The htaccess file in my public_html is not working.


As a test try putting the above line in the .htaccess file in xampp\htdocs\xampp directory like I tested it with above and go to http://localhost and see if your .htaccess works as it should.

RedirectMatch uses the mod_alias module.
Check in your xampp\apache\conf\httpd.conf file that the module is not commented out, it should look like this:
LoadModule alias_module modules/mod_alias.so

PostPosted: 19. October 2006 02:15
by GetFree
How weird.
I put the .htaccess file in my xampplite\htdocs directory and it worked flawlessly.

But it doesn't work on my other virtual host.

I'm gonna cry :cry:

What could be the problem??

PostPosted: 19. October 2006 02:25
by Izzy
GetFree wrote:How weird.
I put the .htaccess file in my xampplite\htdocs directory and it worked flawlessly.

But it doesn't work on my other virtual host.

I'm gonna cry :cry:

What could be the problem??


Thats what I thought and why I asked you to do the test. It is obviously not the .htaccess file more likely a vhosts file issue.
Paste the vhost file or the container that is making you cry. :)
You can obfuscate any sensitive info you dont want on the forum as long as the containers are intact.

PostPosted: 19. October 2006 02:48
by GetFree
This is it:


<VirtualHost *:80>
ServerName myVHost
ServerAlias myVHost*
DocumentRoot "D:/myVHost/www"

</VirtualHost>

PostPosted: 19. October 2006 02:53
by Izzy
GetFree wrote:This is it:


<VirtualHost *:80>
ServerName myVHost
ServerAlias myVHost*
DocumentRoot "D:/myVHost/www"

</VirtualHost>


Try this:
Code: Select all
<VirtualHost *:80>
ServerName myVHost
ServerAlias myVHost*
DocumentRoot "D:/myVHost/www"
<Directory "D:/myVHost/www" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

PostPosted: 19. October 2006 03:30
by GetFree
Damn it...

That did the trick

Thank you, Izzy.

Would you help me with a mod_rewrite problem I have??

I want to strip out the .php extencion of all my URLs without renaming the .php files.

I tried using:
RewriteRule /[^/\.]+$ %{REQUEST_FILENAME}.php

but I havn't been successfull.

PostPosted: 19. October 2006 03:44
by Izzy
GetFree wrote:Damn it...

That did the trick

Thank you, Izzy.

Would you help me with a mod_rewrite problem I have??

I want to strip out the .php extencion of all my URLs without renaming the .php files.

I tried using:
RewriteRule /[^/\.]+$ %{REQUEST_FILENAME}.php

but I havn't been successfull.

Did you uncomment the mod_rewrite module in the httpd.conf file?
It is commented by default.

Turn it on:
RewriteEngine on
RewriteBase /
RewriteRule /[^/\.]+$ %{REQUEST_FILENAME}.php

Your rule is regex so that is what you will need to check. Me not too clever with regex ;)

PostPosted: 19. October 2006 03:50
by GetFree
Yes, I uncommented it.
I did it after you told me about mod_alias could be commented

PostPosted: 19. October 2006 04:48
by GetFree
does xampp lite support mod_rewrite??

I did a test on my webhosting server and it works fine
But on my local web server it doesn't

any idea??

PostPosted: 19. October 2006 05:23
by underdone
It supports mod rewrite. Edit your httpd.conf and remove the # from in front of LoadModule rewrite_module modules/mod_rewrite.so

Then restart the server and it should be working.