Re: Re: Search like php.net's URL thingy
| From: | Nate Tallman | Date: | Thu, 05 Jun 2008 20:03:54 +0000 |
| Subject: | Re: Re: Search like php.net's URL thingy | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275084@lists.php.net to get a copy of this message | ||
Not true, Apache does return a 404, but IE will use the custom 404 page if
it is available.
Nate
On Thu, Jun 5, 2008 at 2:57 PM, Shawn McKenzie <nospam@mckenzies.net> wrote:
> As far as I remember, errordocument still send the code, in this case 404
> to the client. In the case of IE, this will display IEs built-in error doc
> if the server supplied one is < 512 Bytes. Maybe other implications for
> spiders also. I might be wrong, but this is from some old memory.
>
> -Shawn
>
> Nate Tallman wrote:
>
>> 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@connectivhealth.com
>> <mailto:nate.tallman@connectivhealth.com>>
>> 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@mckenzies.net
>> <mailto:nospam@mckenzies.net>> wrote:
>>
>> Ryan S wrote:
>>
>> Hey,
>> one of the things that make the php.net
>> <http://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 <http://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
>> <http://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
>>
>>
>>
>>