Forum Moderators: phranque
(1) The graphics folder is not accessible now. The url would be www.example.info/graphics/image.jpg. It applies the url rules and I can not get images to display.
(2) How to handle the error.php file? If a url is www.example.info/test/ and someone types in www.example.info/tes/ it does not automatically forward to error.php unless the file ends in dot something ie .html or .php. Should I use a meta refresh?
Here is my htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
ErrorDocument 404 /error.php
RewriteCond %{REQUEST_URI} ^[^\.]+[^/]$
RewriteRule ^(.*)$ http://www.example.info/$1/ [R=301,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?rootcatname=$1&catname=$2&lastcatname=$3&itemurl=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?rootcatname=$1&catname=$2&lastcatname=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?rootcatname=$1&catname=$2 [L]
RewriteRule ^([^/.]+)/?$ /index.php?rootcatname=$1 [L]
RewriteCond %{HTTP_HOST} ^example\.info [NC]
RewriteRule (.*) http://www.example.info/$1 [R=301,L,NC]
Thank you for the past and future help
(1) The graphics folder is not accessible now. The url would be www.example.info/graphics/image.jpg. It applies the url rules and I can not get images to display.
RewriteCond %{REQUEST_URI} !^/graphics/
(2) How to handle the error.php file? If a url is www.example.info/test/ and someone types in www.example.info/tes/ it does not automatically forward to error.php unless the file ends in dot something ie .html or .php. Should I use a meta refresh?
Never use meta-refresh. Ever. Unless you are forced by a criminal gang to host on GeoCities or something... :)
If you rewrite all requests to your script, then the script must decide if something "exists" or not. You will need to think about it it for several days, and decide exactly how the script can determine if something "exists" or not. If the script can't generate and serve something in response to a request, then the script should output a properly-formed 404 error response, and a message for the visitor to read that explains what happened.
PHP provides the "Header" function to output 403, 404, 410, and other error response headers:
header("HTTP/1.1 404 Not Found");
echo "full HTML code of 404 error document here";
[edited by: jdMorgan at 7:08 pm (utc) on July 22, 2007]
I assume that the rewrite rules for pages could be put inside a <files "\.(htm?l¦php)$"> container so that only calls for "pages" would be rewritten.
Or did I miss something?
That would avoid having to add a negative match condition to each and every existing rewrite rule.
Well no. It needs to go in front of any of the rules that might otherwise match the /graphics URL-path... I didn't finish that thought in my previous post... Pesky work interfering!
Or you could use a 'skip rule' to bypass all of those rules when the /graphics URL-path is requested...
Jim