Ik betaal geen cent maar kan het gewoon lezen. Iig, sorry dat ik hier nu de layout verneuk, maar hier komt dat draadje
In PHP
HTTP_REFERER wont be set since it was redirected
QUERY_STRING is only for current page
REQUEST_URI is only for current page
You can try putting this in your apache http.conf file or a .htaccess file.
----------------------
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$
http://www.mysite.com/404.php?url=$1 [L]
-----------------------
Will check the requested file if it exists. If it doesnt then it wil reidrect to your page appending the requested file as a variable $_GET variable.
Regards.
Nick
Comment from gesf
Date: 07/03/2004 11:49PM PDT
Author Comment
Hi Nick, thanks for your reply!
The error thing is working fine. I´ve made same changes for my needs. It´s now redirecting to the error page and showing the searched file/url and keeps it in the address bar.
Here is what i have:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ site/error/404.php?url=$1 [L]
'site' is my website folder, i don´t have it in the root, so i always need to specify it.
The problem is that i´m using the 'DirectoryIndex' and other 'rewrites' and if i don´t specify the directory´s default page in the url it goes to the error page. The same to other 'rewrites'... they fail!
Don´t know if it matters, but i´m using: Options ExecCGI FollowSymLinks Includes MultiViews, so the rewrites can work!
Any idea!?
Sincerely,
Gesf
Comment from CrYpTiC_MauleR
Date: 07/04/2004 05:04AM PDT
Comment
Could you paste your other rewrites and settings here? Thanks!
Comment from gesf
Date: 07/04/2004 09:55PM PDT
Author Comment
Of course! Here goes:
RemoveHandler .html .htm .xhtml
AddType application/x-httpd-php .php .html .htm .xhtml
AddHandler cgi-script .cgi .pl
# This one fails if don´t specify the default page in the url.
DirectoryIndex site.php default.php
<FilesMatch "\.(ht|ini)$">
Order allow,deny
Deny from all
</FilesMatch>
Options ExecCGI FollowSymLinks Includes MultiViews
RewriteEngine On
RewriteBase /
# This one fails too... to the 404 error page!
RewriteRule ^/tutorials/(.*)/(.*).htm site/tutorials/?tutcat=$1&tutid=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ site/error/404.php?url=$1 [L]
ErrorDocument 400
http://127.0.0.1/site/error/400.php
ErrorDocument 401
http://127.0.0.1/site/error/401.php
ErrorDocument 403
http://127.0.0.1/site/error/403.php
# ErrorDocument 404
http://127.0.0.1/site/error/404.php
... and so on with this. They are the last thing!
I was wrong! Is just the DirectoryIndex which isn´t working! The other rewrite fails:
"... tutorials/?tutcat ...". Because i´m not passing the default dir page!
But... i want to use it
Thanks in advance!
Comment from gesf
Date: 07/04/2004 10:23PM PDT
Author Comment
Another thing!
Using the the code you gave me, i can´t view .htm or .html files. Just .php... strange!
Thanks
Comment from ahoffmann
Date: 07/05/2004 03:02AM PDT
Comment
stupid question: why do you redirect for error pages?
if apache just uses rewrite rules all server variables (like REFERER) should be available
Comment from gesf
Date: 07/05/2004 05:50AM PDT
Author Comment
Hey ahoffmann,
Yes, the referer is available, but (using ErrorDocument):
I request a page to the server and if it didn´t find it, it will redirect me to the error page. That´s when i loose the referer. Like CrYpTiC_MauleR said, in php, the referer won´t be set since it was redirected. So the idea is to catch the referer (before the error) and send it with the error page... as a variable. That´s what does that rewrite rule.
BTW CrYpTiC_MauleR: I try to find, but i couldn´t! What does " !-f " means?
Regards
Gesf
Comment from ahoffmann
Date: 07/05/2004 06:56AM PDT
Comment
!-f
means: if file not exists, or is not a file
Comment from gesf
Date: 07/05/2004 10:03AM PDT
Author Comment
Thanks

Well, the rewrite is working, the only problem is that DirectoryIndex fails with it

Regards