.htaccess are not working

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

Postby GetFree » 19. October 2006 07:07

I did uncomment it.

But it still doesn't work.

I wonder why.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby Izzy » 19. October 2006 11:42

I came across a mod_rewrite tutorial and thought it would be worth reproducing them on the forum here for those readers with the need to understand mod-rewrite a little better.

GetFree, item 10 looks interesting as I was going to ask where you have your rule located httpd.conf or .htaccess. There seems to be some differences worth noting.

I created a new topic to prevent clutter in this topic and hopefully to give it a chance to be made a sticky topic by the admin/mods.

Link is here:
http://community.apachefriends.org/f/viewtopic.php?t=20957
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby GetFree » 20. October 2006 03:13

Thank you, Izzy. That tutorial is great.
All my problems are solved now. Thank you.


One last question:
What is the difference between "FollowSymLinks" and "+FollowSymLinks"??

That was the reason why my rewrite directive wasn't working.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby Izzy » 20. October 2006 03:28

GetFree wrote:Thank you, Izzy. That tutorial is great.
All my problems are solved now. Thank you.


One last question:
What is the difference between "FollowSymLinks" and "+FollowSymLinks"??

That was the reason why my rewrite directive wasn't working.

I am pleased that all is now working for you. It must have been a long a frustrating road to travel. :)

This may help with your question:
http://httpd.apache.org/docs/2.2/mod/core.html#options
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby GetFree » 20. October 2006 04:07

Now that I hid the .php from my public URLs, I want to send a 404 for every request to a .php file.

So I did the following:

RedirectMatch 404 \.php$

which works fine.

But the error page is the default apache error.
I want to show a custom error page, so I tried the following:

RedirectMatch 404 \.php$ /error.html

But it didn't work.

I dont know whether that directive will serve to do what I want.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby GetFree » 20. October 2006 04:51

Aside the custom error page... I have one more problem. :(


Since I want to retrive an error for every request for a .php file on my server, I added the directive
RedirectMatch 404 \.php$

But the special case of the directory index file (index.php) is causing me problems.

What I want to avoid is to rename my php files.
So I added the directive
RewriteRule ^([^\.\?]+)(\?.*)?$ $1.php$2

to rewrite requests to files without extension to the actual .php files.

The problem comes on the case the user request a directory.
In that case apache will look for the default index.php file and then retrieve a 404 error because I added the "RedirectMatch 404 \.php$" directive.

What I tried to bypass that was to add "DirectoryIndex index" to the .htaccess file. That way apache will look for "index" instead of "index.php" and then the "...../index" url will be rewritten internaly to "...../index.php"

Nevertheless... the "DirectoryIndex index" aproach didn't work.
So... now I'm gonna cry again. :(

Izzy, man...
would you help me??

I want to avoid at any cost to rename my .php files.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby Izzy » 20. October 2006 05:21

Not sure if this will help:
http://httpd.apache.org/docs/2.2/mod/mo ... ndexignore

Also try -indexes

I think using this list of directives:
http://httpd.apache.org/docs/2.2/mod/directives.html
and the info some of them contain and some heavy reading you may find your answers, as frustrating as it seems.
It's all part of the learning curve we have to go through.
Half the battle is knowing where to look for this knowledge.

The Apache docs, though seemingly daunting at first, are really very comprehensive and will be your friend time after time.

Sorry I can't answer your specific question, I wish I could, but I can point you to where you may find your answers. Then you can apply what you find to your specific needs.

Good luck with it as I believe you have come along way down the mod-rewrite road already.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby Izzy » 20. October 2006 08:17

GetFree wrote:Now that I hid the .php from my public URLs, I want to send a 404 for every request to a .php file.

So I did the following:

RedirectMatch 404 \.php$

which works fine.

But the error page is the default apache error.
I want to show a custom error page, so I tried the following:

RedirectMatch 404 \.php$ /error.html

But it didn't work.

I dont know whether that directive will serve to do what I want.


In your httpd.conf file you commented out the link to the custom error pages in the extra directory from an earlier post, I believe.

So add this to your .htaccess file after creating and naming your custom error page (the name of the file is your choice, I used 404.htm as an example):
ErrorDocument 404 /404.htm
Put the page in the same place as the .htaccess file if using the above path or you can use a full path to where ever you want to put the error page. You can even use http://blah/blah/404.html etc.

You can customize other error pages for example:
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html
ErrorDocument 405 /405.htm

You can even use SSI to add environment variables to spruce up the error page with what appears as very knowledgable messages like these for example:
Code: Select all
You were referred from this page:    <!--#echo var="HTTP_REFERER" -->
Your IP address shows as:    <!--#echo var="REMOTE_ADDR" -->
Your web browser says it is:    <!--#echo var="HTTP_USER_AGENT" -->
You requested this page (error):    http://<!--#echo var="HTTP_HOST" --><!--#echo var="REQUEST_URI" -->
The HTTP Status (error) Code is:    <!--#echo var="REDIRECT_STATUS" -->

Remember to use the .shtml file extension so Apache knows what it is.

I don't know if this will affect the same issue you had when we commented out the httpd-multilang-errordoc.conf or if you are still using that mod_rewrite rule or not.

This custom error can also be change on a global basis from within the httpd.conf file using this block of entries:
Code: Select all
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Previous

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 42 guests