![]() |
|
#1
|
|||
|
|||
SE Friendly URLs Apache Bug?Hi all,
I am trying to create search engine friendly urls on my site using a well discussed method. example: sitename which allows "myprog" to run without being called "myprog.php" and passing the two parameters... I am running Win2K and I've tried 3 versions of Apache: 1.3.27, 2.0.46, and 2.0.47 *** The problem is, I get a 404 error page because Apache is not backtracking the URL to find out that "myprog" is a valid PHP script. Apparently this is to do with the "AcceptPathInfo On" directive when using Apache versions over 2.0 I just can't get it to work under Win2k. Does this make sense to anyone? Please help if you can - this is really pissing me off. - James |
|
#2
|
||||
|
||||
Search engine friendly URLS using PHP's $_SERVER['PATH_INFO']First of all, NO it's not a bug.
The problem why that URL doesn't work for you is because: You were trying to fetch myprog.php just using the filename without the extension. That simply won't work no matter how intuitive you think Apache usually is. If you had requested this instead, you will see that your link will work: http://www.example.com/myprog.php/param1/param2; note the .php extension in the link. Solution: Apache's <Files></Files> Directive Create or modify your .htaccess file and add the following lines to it: Code:
Next, rename myprog.php to just myprog Now, linking to http://www.example.com/myprog/param1/param2 will / should work! By the way, the variable that you will be looking for ultimately is: $_SERVER['PATH_INFO']. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
Quote:
Sorry, I should have mentioned that I did all that. I know it's working because when I run the file without the parameters it works fine: mysite The script just like that works fine. It's when I tack on: mysite Then it gives me problems (file not found). That's why it just doesn't make sense to me... I had to do the files directive in the Apache config file because I couldn't get the .htaccess to work under windows. Is that possible to use the .htaccess under windows? I saw that there was an apache option for it in the config, but it didn't seem to work... Anyway, thanks, James |
|
#4
|
||||
|
||||
|
I am certain .htaccess files work on Windows since I use Windows ME myself and I use it all the time when I test my rewritten urls.
It can't be the .htaccess since you say that you've already got http://www.example.com/myprog working... I can't imagine how you got that done without .htaccess being set up or setting it up directly in Apache's httpd.conf __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
|||
|
|||
|
It was simple without using the .htaccess file.
All I did was put this in the file section of the conf. file: <Files myprog> ForceType application/x-httpd-php </Files> I am running it from the root - I assume it would work fine for sub folders as well... It just pisses me off tho because I'm running Apache 1.3.27 right now, which by default is supposed to have that AcceptPathInfo on automatically, but it gives 404 if I send those parameters... |
|
#6
|
||||
|
||||
|
Trust me... I've just tested it myself and it works like a charm.
I am on Windows ME, Apache 1.3.27 and using virtual hosts. I type http://www.example.com/myprog/param1/param2 and I get the page off 'myprog'. In my 'myprog' file I have the following PHP scriplet: PHP Code:
You might want to make sure you have no other subfolders that even resembles /param1 or /param2 Also, try a different filename... BTW, I have not heard of AcceptPathInfo till today __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#7
|
|||
|
|||
|
Ok I have my .htaccess file working now... BUT it still gives me "File not found" when I include parameters as in...
www.example.com I tried changing the file name of "myprog" and using different parameters that weren't folders and I modified my code to match yours - but still no goat... I am using the virtualhost directives as well to have multiple sites locally... Here's the one for this particular site: Code:
Does yours look much different? Thanks |
|
#8
|
||||
|
||||
|
I suggested the change in filename simply cause I know how evil browser caches can be
I didn't think you'd go and set up virtual hosts on me... hang on, I will be back with my virtual hosts bit off the httpd.conf file I have. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#9
|
||||
|
||||
Named virtual hosts on Windows ME / ApacheHere's an extract from mine (httpd.conf):
Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#10
|
|||
|
|||
|
I just copied what you had (putting in my custom settings) and no dice...same old same old...
If there's anything that annoys me about computers/programming it is TOTALLY this. What should have taken 5 minutes last night has now taken 7 hours....but ahhh.... the programmer's life... Maybe it's something to do with Windows 2000 versus ME, but you'd think others would run into the same problem and there'd be more about it on the net.... Thanks for your time though... James |
Recent GIDBlog
Last Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| apache php no longer working (MX??) XP?? | ChicoMendez | Apache Web Server Forum | 5 | 30-Aug-2004 10:51 |
| connect tomcat to apache | kefen | Apache Web Server Forum | 0 | 11-Dec-2003 22:13 |
| Redirect multiple URLs to one script, masking true URL | Maccaday | Apache Web Server Forum | 1 | 10-Dec-2003 08:34 |
| Apache In Windows Xp | JUNK KED | Apache Web Server Forum | 8 | 30-Nov-2003 08:48 |
| Apache multiple localhosting - desperate! | jnorris | Apache Web Server Forum | 8 | 23-Nov-2003 23:55 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The