If user visits /abc,
and there is no file/directory named abc under /,redirect it to /test.php?from=abc,
but if it exists,don’t redirect.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
RewriteCondis a conditional – the following rule will only execute if the condition is true.The
-ftest checks if a file exists, the-dtest checks if a directory exists.SCRIPT_FILENAMEwill be set to the system path that Apache would use to fetch a file (e.g./var/www/html/blah.html)So it checks to see that the file doesn’t exist, then it checks to see that the directory doesn’t exist. If both those conditions are met, it processes the rule.
Example:
DOCUMENT_ROOTis set to/var/www/htmlhttp://yoursite/blah.html/var/www/html/blah.htmlis a file/var/www/html/blah.htmlis a directoryhttp://yoursite/test.php?from=blah.htmlDocumentation for RewriteCond