apache - How do I redirect a URL that isn't found without sending a 404 header? -
my website needs .htaccess
file redirect user index.php
when page not found. however, not want apache send 404 header document.
i asked question earlier: apache .htaccess 404 error redirect
the command "errordocument /index.php"
produces exact effect want, except sends 404 header page. can do? should overwrite 404 header php?
add .htaccess
file:
rewriteengine on rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^.*$ index.php [nc,l]
- enable rewrite
- check if requested file exists regualar file size (not empty)
- check if requested file link
- check if requested file directory
- if 1 of previous 3 statements true show file
- otherwise go index.php
if redirect index.php happens u can requested uri using $_server["request_uri"]
inside index.php
- '-d' (is directory) treats teststring pathname , tests if exists , directory.
- '-f' (is regular file) treats teststring pathname , tests if exists , regular file.
- '-s' (is regular file size) treats teststring pathname , tests if exists , regular file size greater zero.
- '-l' (is symbolic link) treats teststring pathname , tests if exists , symbolic link.
- '-f' (is existing file via subrequest) checks if teststring valid file , accessible via server's currently-configured access controls path. uses internal subrequest determine check, use care because decreases servers performance!
- '-u' (is existing url via subrequest) checks if teststring valid url , accessible via server's currently-configured access controls path. uses internal subrequest determine check, use care because decreases server's performance!
more information: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
edit: please notice post: https://stackoverflow.com/questions/486505/mod-rewrite-with-godaddy
Comments
Post a Comment