Forum Moderators: phranque

Message Too Old, No Replies

RewriteCond %{REQUEST_URI}!-U

What means?

         

Dapuzz

9:45 am on Feb 4, 2005 (gmt 0)

10+ Year Member



Hi all.
this is my first post in English, so... sorry for mispelled wolds
Well
i've found in mod_rewrite explamples in official apache guideline the string
RewriteCond %{REQUEST_URI}!-U

my question is:
where i can read something about the last parameter !-U
-f == file
-d == Directory...
what means!-U
Thanks

In backgroud:
I want to redirect all 404 errors to a custom page but i want to remember the requested page.
whit


ErrorDocument 404 my_page.php

the php requested_uri was always my_page.php
now i want to redirect to my_page.php?page=$requested_uri
it is possible?

Dapuzz

11:11 am on Feb 4, 2005 (gmt 0)

10+ Year Member



reply to myself

'<CondPattern' (is lexically lower)
Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically lower than CondPattern.
'>CondPattern' (is lexically greater)
Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically greater than CondPattern.
'=CondPattern' (is lexically equal)
Treats the CondPattern as a plain string and compares it lexically to TestString. True if TestString is lexically equal to CondPattern, i.e the two strings are exactly equal (character by character). If CondPattern is just "" (two quotation marks) this compares TestString to the empty string.
'-d' (is directory)
Treats the TestString as a pathname and tests if it exists and is a directory.
'-f' (is regular file)
Treats the TestString as a pathname and tests if it exists and is a regular file.
'-s' (is regular file with size)
Treats the TestString as a pathname and tests if it exists and is a regular file with size greater than zero.
'-l' (is symbolic link)
Treats the TestString as a pathname and tests if it exists and is a symbolic link.
'-F' (is existing file via subrequest)
Checks if TestString is a valid file and accessible via all the server's currently-configured access controls for that path. This uses an internal subrequest to determine the check, so use it with care because it decreases your servers performance!
'-U' (is existing URL via subrequest)
Checks if TestString is a valid URL and accessible via all the server's currently-configured access controls for that path. This uses an internal subrequest to determine the check, so use it with care because it decreases your server's performance!

But it seems to doesn't work

jdMorgan

4:19 pm on Feb 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dapuzz,

Welcome to WebmasterWorld!

The problem is with the variable name -- Use REQUEST_FILENAME instead.


# If resource does not exist as a filename and does not exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite to script with requested URL as parameter
RewriteRule (.*) /my_page.php?page=$1 [L]

Alternatively, your could define /my_page.php as your ErrorDocument, and then extract the requested URL within /my_page.php using the same server variables.

Jim

Dapuzz

11:58 pm on Feb 4, 2005 (gmt 0)

10+ Year Member




Alternatively, your could define /my_page.php as your ErrorDocument, and then extract the requested URL within /my_page.php using the same server variables.

Jim


if you could tell me how extract the requested URL pls.
both $_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'] php variables show me the page of error handling and not the url requested by the user.

it is possible to not show user in the address bar the redirection?

thanks a lot.

jdMorgan

12:40 am on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> it is possible to not show user in the address bar the redirection?

The code I posted above does not do a redirect, it does a server-internal rewrite. Therefore, it does not affect the client's address bar.

I'm not a PHP guru, so your question about server variables may get a faster response in our PHP forum.

Jim

Dapuzz

8:46 am on Feb 5, 2005 (gmt 0)

10+ Year Member



ok, sorry, i repeat in another way my question to do what i have to do :D

can "save" what the user type in the addres bar (%{REQUEST_FILENAME} or %{REQUEST_URI}) using the "error document"?
Something like this:

ErrorDocument 404 http://www.mysite.com/error.php?code=404&page=%{REQUEST_FILENAME}

or

ErrorDocument 401 http://www.mysite.com/error.php?code=401&page=%{REQUEST_FILENAME}

or i need a perl script to do this?