GIDForums  

Go Back   GIDForums > Web Hosting Forums > Web Hosting Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Jul-2003, 21:37
JamesRxx555 JamesRxx555 is offline
New Member
 
Join Date: Jul 2003
Posts: 11
JamesRxx555 is an unknown quantity at this point

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  
Old 11-Jul-2003, 01:58
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

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:
<Files myprog> ForceType application/x-httpd-php </Files>

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'].
  #3  
Old 11-Jul-2003, 07:37
JamesRxx555 JamesRxx555 is offline
New Member
 
Join Date: Jul 2003
Posts: 11
JamesRxx555 is an unknown quantity at this point
Quote:
<Files myprog>
ForceType application/x-httpd-php
</Files>


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  
Old 11-Jul-2003, 08:04
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
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
  #5  
Old 11-Jul-2003, 08:13
JamesRxx555 JamesRxx555 is offline
New Member
 
Join Date: Jul 2003
Posts: 11
JamesRxx555 is an unknown quantity at this point
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  
Old 11-Jul-2003, 08:22
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
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:

<?php
echo "<pre>\\n";
print_r( $_SERVER );
echo "</pre>\\n"
?>


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
  #7  
Old 11-Jul-2003, 08:41
JamesRxx555 JamesRxx555 is offline
New Member
 
Join Date: Jul 2003
Posts: 11
JamesRxx555 is an unknown quantity at this point
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:
<VirtualHost *> ServerAdmin webmaster@mysite DocumentRoot "c:/mysite" ServerName mysite ServerAlias *.mysite ErrorLog logs/site1-error.log ScriptAlias /cgi-bin/ "c:/mysite/cgi-bin/" <Directory "c:/mysite"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>


Does yours look much different?

Thanks
  #8  
Old 11-Jul-2003, 08:55
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
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.
  #9  
Old 11-Jul-2003, 09:00
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Named virtual hosts on Windows ME / Apache


Here's an extract from mine (httpd.conf):

Code:
# # Use name-based virtual hosting. # NameVirtualHost 127.0.0.1:80 # some other sites followed by... <virtualhost 127.0.0.1> ServerName www.example.com ServerAdmin admin@localhost DocumentRoot "/home/example/public_html" <Directory /> Options FollowSymLinks AllowOverride All </Directory> </virtualhost>
  #10  
Old 11-Jul-2003, 09:08
JamesRxx555 JamesRxx555 is offline
New Member
 
Join Date: Jul 2003
Posts: 11
JamesRxx555 is an unknown quantity at this point
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 GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 01:59.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.