Forum Moderators: phranque

Message Too Old, No Replies

Apache treats no extension as if it was a directory = 404

         

AngelusWebDesign

6:07 am on Sep 28, 2010 (gmt 0)

10+ Year Member



On my website,

[domain.com...]

takes the user to a more complicated URL.

However, on my new development machine (Linux, latest version of Apache, PHP, MySQL, etc.) Apache is treating the request

[domain.com...]

like I want to go to the directory "Descriptive-Url-Used-Here" and gives me a 404 error.

I wasn't expecting this at all -- any suggestions?

Thanks,

Matthew

jdMorgan

1:54 pm on Sep 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume you're using mod_rewrite in .htaccess to map "friendly" URLs to one or more scripts, plus query strings?

If so, mod_negotiation and AcceptPathInfo can interfere with your rules, passing the request to mod_dir before your rule(s) can execute.

The solution is to add the "-MultiViews" switch to your "Options" directive, and (if on Apache 2.x) add "AcceptPathInfo Off" to your .htaccess code.

Jim

AngelusWebDesign

3:47 pm on Sep 28, 2010 (gmt 0)

10+ Year Member



I'll try switching off "AcceptPathInfo" just to see what happens --

But I'm not using mod_rewrite to do anything with the URL itself -- I just have a snippet to redirect "domain.com" to "www.domain.com" which I have on 2 other webservers with no problem, so that can't have anything to do with it.

I'm doing some conversion of the URL, but I'm doing it in PHP. "index.php" should be called, and it takes everything after itself "/Descriptive-url-goes-here" and does a MySQL lookup, etc. to figure out what page should be displayed. This code is 100% the same as it is on a production server right now, with no problems.

The problem I'm experiencing has to be due to some setting I need to change in Apache/PHP, since I have this new LAMP setup on my new Linux machine. I know it has to be relatively easy -- I just don't know where to begin.

Thanks,

Matthew

AngelusWebDesign

3:51 pm on Sep 28, 2010 (gmt 0)

10+ Year Member



Interestingly, I have a relatively new Apache2.2/MySQL5/PHP5 setup on my Windows PC -- maybe 6 months old -- which I installed myself (downloaded each separately) and it has no problems with the same code I'm trying to run.

Why would the Linux version of A/M/P have different settings than the Windows version?

I did install some kind of Apache-PHP linkage module, and some kind of MySQL-PHP thingy when I was setting things up on Linux -- could that be the culprit? (By the language I'm using, you can tell how well I understand what I installed). I was just trying to get the dev. environment going on my new Linux box as quickly as possible.

Matthew

g1smd

4:11 pm on Sep 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



URLs like example.com/index.php/descriptive-word are non-optimum for several reasons. The slash after index.php is a bad idea; in fact, including index.php in the URL isn't even required.

Your script should be processing server internal requests such as /index.php?value=descriptive-word BUT with a simple mod-rewrite addition you can use URLs such as example.com/descriptive-word instead.

That's a much better scenario.

I prefer example.com/001-descriptive-word as the URL, and mod_rewrite internally passes /index.php?number=001&value=descriptive-word to the script. The script then does a check to see if 001 is a valid article number and returns a 404 error if not. It also checks to see if descriptive-word is the correct wording for that article number, and sends a 301 redirect to the correct URL if it is not. If everything matches up (including casing of the words) then the article is served by the script.

AngelusWebDesign

5:01 pm on Sep 28, 2010 (gmt 0)

10+ Year Member



Once I added "AcceptPathInfo On" to my Apache2.conf file and restarted Apache, things started to work again.

Thanks for the lead.

Matthew