SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search with error 404

    Hello,

    In a htaccess file, you can define the page where the server has to go to when someone reaches a page or directory that doesn't exist. That's no problem, but I want to pass the name of the directory or file to a file like this: search.php?query=<name_of_dir/file>

    Is that possible?

  2. #2
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    PHP Code:
    $pass_str "name_of_dir/file";
    $encoded urlencode($pass_str);
    echo 
    "<a href=\"search.php?query=$encoded\">zbc</a>"

  3. #3
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, but how do I pass the name of the error dir/file from htaccess to a php file?

  4. #4
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    provided you're not using the same error page for multiple virtual hosts, i think the $_SERVER["REQUEST_URI"] variable should hold the address of the file/directory that doesn't exist/created the 404 error. just tell apache to go to your error-handling script for a 404, and in said script use the variable above...

    you mileage may vary...i haven't tested this
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •