Welcome to MobyThreads.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

PATH_INFO rewrite

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Related Topics:
Mod Rewrite - Hello, I have writen this script in on / pers/(.*) [L,R] It is ok, infact if i write: it redirecto to:..

Mod rewrite and OSX - Hi, is loaded in but it does not work, is that something I missed ? Coluche

rewrite url - Hi, I have two domain names on the same (IP-host based). How can I redirect one of the domains to another ? Regards and the best wishes for 2004. Michael

Mod rewrite - Hallo, I have write in a .htaccess File something like this: On !-d !-f [L] I..

mod-rewrite - I am to use to chnage my created pages into static urlls for search engine I am unable to get the rewrite to work, it doesn't seem to do anything. Here is the code on
Next:  Apache: Weard SEARCH requests in access_log  
Author Message
user2842

External


Since: Jun 24, 2004
Posts: 3



(Msg. 1) Posted: Thu Jun 24, 2004 6:13 am
Post subject: PATH_INFO rewrite
Archived from groups: alt>apache>configuration (more info?)

Hello everyone,

I would like to know if it is possible to setup the
following scenario using Apache 2.x:

lets say a browser requests the following url:

http://www.mysite.com/faq/general

in htdocs i have the following structure:

htdocs/faq/general
htdocs/faq/index.php
htdocs/faq/general/index.html

I want the following:

if the file htdocs/faq/general/index.html _exists_ then
apache should return it

otherwise apache should call the file

htdocs/faq/index.php

and pass PATH_INFO = general

I do not require that the directory structure
stays as described, just an easy/elegant solution
to implement this scenario. If possible, I would
prefer avoiding mod_rewrite.

Any help will be really appreciated!

George Moschovitis

 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 2) Posted: Thu Jun 24, 2004 1:43 pm
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

George Moschovitis <gm.DeleteThis@navel.gr> wrote:
 > lets say a browser requests the following url:
<font color=purple> > <a style='text-decoration: underline;' href="http://www.mysite.com/faq/general</font" target="_blank">http://www.mysite.com/faq/general</font</a>>
 > I want the following:
 > if the file htdocs/faq/general/index.html _exists_ then
 > apache should return it
 > otherwise apache should call the file
 > htdocs/faq/index.php
 > and pass PATH_INFO = general

echo "ErrorDocument 404 /faq/index.php?PATH_INFO=general" > htdocs/faq/.htaccess

If you allow the use of .htaccess files of course.

Davide


--
| Love is the triumph of imagination over intelligence.
|
|
|<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
user2842

External


Since: Jun 24, 2004
Posts: 3



(Msg. 3) Posted: Fri Jun 25, 2004 4:37 am
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Davide Bianchi <davideyeahsure.RemoveThis@onlyforfun.net> wrote in message news:<2jvphnF169gnnU4.RemoveThis@uni-berlin.de>...
 > echo "ErrorDocument 404 /faq/index.php?PATH_INFO=general" > htdocs/faq/.htaccess

Hello,

this is clever but doesnt solve my problem. I need to pass
a parameter to index.php not a hardcoded constant, ie:

i want the call the url:

<a style='text-decoration: underline;' href="http://www.mysite.com/faq/XXXXX" target="_blank">http://www.mysite.com/faq/XXXXX</a>

transformed to

<a style='text-decoration: underline;' href="http://www.mysite.com/faq/index.php/XXXXX" target="_blank">http://www.mysite.com/faq/index.php/XXXXX</a> (PATH_INFO)

if and only if the file:

htdocs/faq/XXXXX/index.html

does not exist.


Is this possible ? Thanks in advance for any help

George Moschovitis
Navel Ltd

--
<a style='text-decoration: underline;' href="http://www.joy.gr" target="_blank">http://www.joy.gr</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 4) Posted: Fri Jun 25, 2004 1:07 pm
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

George Moschovitis <gm DeleteThis @navel.gr> wrote:
 > this is clever but doesnt solve my problem. I need to pass
 > a parameter to index.php not a hardcoded constant, ie:

Then remove the hardcoded constant and from your php file check
the REQUESTED_URI environment variable. It should do it.

Davide

--
| CChheecckk yyoouurr dduupplleexx sswwiittcchh..
|
|
|<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
user2842

External


Since: Jun 24, 2004
Posts: 3



(Msg. 5) Posted: Fri Jun 25, 2004 1:23 pm
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 > Then remove the hardcoded constant and from your php file check
 > the REQUESTED_URI environment variable. It should do it.

ehm i feel stupid, in retrospect it seems so obvious.
Thank you!

-g.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 6) Posted: Fri Jun 25, 2004 5:56 pm
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Davide Bianchi wrote:

 > George Moschovitis <gm.TakeThisOut@navel.gr> wrote:
 >
  >>lets say a browser requests the following url:
  >>http://www.mysite.com/faq/general
  >>I want the following:
  >>if the file htdocs/faq/general/index.html _exists_ then
  >>apache should return it
  >>otherwise apache should call the file
  >>htdocs/faq/index.php
  >>and pass PATH_INFO = general
 >
 > echo "ErrorDocument 404 /faq/index.php?PATH_INFO=general" > htdocs/faq/.htaccess

Do you really want to send a 404 Error to the search engine?? Try
something along the lines of:

# check if request is for an existing directory,
# if it is, let the request go through
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule .* [PT]

# if it's not an existing directory
RewriteRule ^([^/]+)/(.*)/?$ $1/index.php?PATH_INFO=$2 [L,NS]

This isn't tested, but it should get you in the right direction...

--
Justin Koivisto - spam.TakeThisOut@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 7) Posted: Fri Jun 25, 2004 5:58 pm
Post subject: Re: PATH_INFO rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Justin Koivisto wrote:

 > Davide Bianchi wrote:
 >
  >> George Moschovitis <gm RemoveThis @navel.gr> wrote:
  >>
   >>> lets say a browser requests the following url:
<font color=brown>   >>> <a style='text-decoration: underline;' href="http://www.mysite.com/faq/general</font" target="_blank">http://www.mysite.com/faq/general</font</a>>
   >>> I want the following:
   >>> if the file htdocs/faq/general/index.html _exists_ then
   >>> apache should return it
   >>> otherwise apache should call the file
   >>> htdocs/faq/index.php
   >>> and pass PATH_INFO = general
  >>
  >>
  >> echo "ErrorDocument 404 /faq/index.php?PATH_INFO=general" >
  >> htdocs/faq/.htaccess
 >
 >
 > Do you really want to send a 404 Error to the search engine?? Try
 > something along the lines of:
 >
 > # check if request is for an existing directory,
 > # if it is, let the request go through
 > RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
 > RewriteRule .* [PT]
 >
 > # if it's not an existing directory
 > RewriteRule ^([^/]+)/(.*)/?$ $1/index.php?PATH_INFO=$2 [L,NS]
 >
 > This isn't tested, but it should get you in the right direction...
 >

Also note that the data will be in $_GET['PATH_INFO'] NOT
$_SERVER['PATH_INFO']

--
Justin Koivisto - spam RemoveThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: PATH_INFO rewrite 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]