Re: Re: Search like php.net's URL thingy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ErrorDocument 404 /path/to/some/script.php
* $_SERVER['REDIRECT_URL']

(somehow misplaced underscore)

On Thu, Jun 5, 2008 at 2:50 PM, Nate Tallman <
nate.tallman@xxxxxxxxxxxxxxxxxxx> wrote:

> Why not just set:
> ErrorDocument 404 /path/to/some/script.php
> Then check $SERVER['REDIRECT_URL'] for the failed request.
>
>
>
>
> On Thu, Jun 5, 2008 at 2:41 PM, Shawn McKenzie <nospam@xxxxxxxxxxxxx>
> wrote:
>
>> Ryan S wrote:
>>
>>> Hey,
>>> one of the things that make the php.net site so cool is how easy it is
>>> to find info for a function or a list of topics.. eg:
>>>
>>> http://php.net/arrays
>>> http://php.net/count
>>>
>>> I'm sure nearly all of you reading this have done it more times than you
>>> would care to count, i'm trying to get something like this on my own site
>>> but even after going to php.net and clicking on the view source buttons
>>> am a bit confused.
>>>
>>> basically this is what i am trying, people who type in
>>> http://www.mysite.com/asdf
>>> should not be shown a 404 not found page but instead "asdf" should be
>>> passed onto my script where i can do a search on the term and either give
>>> them back the results of that search or direct them to a custom 404 page.
>>>
>>> since i couldnt find the answer via php.net's source i started messing
>>> around with how i *think* its done... tell me if i am on the correct track:
>>> when someone requests a page that does not exist, a .htaccess file them up
>>> and also takes the page name they were searching for and redirects them to a
>>> script...
>>> So far i have only been able to get the .htaccess file point to my custom
>>> 404 page... but how do i get it to pass the parameter of the not-found-page
>>> to my script?
>>>
>>> Would appreciate any code, tips, urls you can give me.
>>>
>>> Thanks!
>>> Ryan
>>>
>>>
>>>
>>>  ------
>>> - The faulty interface lies between the chair and the keyboard.
>>> - Creativity is great, but plagiarism is faster!
>>> - Smile, everyone loves a moron. :-)
>>>
>>>
>>>
>>>
>>>
>>
>> If you use .htaccess and have mod_rewrite then it is simpler.  Something
>> like this (untested):
>>
>> <IfModule mod_rewrite.c>
>>    RewriteEngine On
>>    RewriteCond %{REQUEST_FILENAME} !-d
>>    RewriteCond %{REQUEST_FILENAME} !-f
>>    RewriteRule ^(.*)$ index.php?term=$1 [L]
>> </IfModule>
>>
>> Then in index.php you can use the contents of $_GET['term'], which in your
>> example would be asdf.
>>
>> [QSA,L] will give you the query string if the user typed in something like
>> http://www.mysite.com/asdf?your=mom.
>>
>> Then $_GET['your'] = 'mom'.
>>
>> -Shawn
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux