1

I have strange problem that need help. It is about rewrite using apache.

Here my .htaccess content file:

Options +FollowSymLinks


 ## This is an example .htaccess-file
 ## To get everything automatically parsed, the following line is needed
 #set link auto on

 ##From now on, every RewriteRule gets recognised.
 RewriteEngine on
 RewriteRule captcha(\.html){0,1}$  captcha.php [QSA,L]
 RewriteCond %{SCRIPT_FILENAME} !-s
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteCond %{SCRIPT_FILENAME} !-f
 Rewriterule (.*) handler.php

 ##You can also change the text before the real link by the following line

With this rule, I am hoping that all request except there is exists in file or directory will be directed to my custom handler: handler.php.

Everyting just fine as expected but this case not:

http://../test/form_login/query=%2Ftest%2Findex.php%3Fpage%3Dform&

Root url: /test/, form_login is not file or directory index.php is exists in the root.

Apache response with : 404 Page Not Found

Thanks for any of your help.

Regards, Steve

5
  • Your formatting got busted in the post. Please try to format the sample .htaccess properly so that we can see it. Commented Jan 7, 2011 at 2:38
  • It would also be helpful if you could list a bunch of example URLs, alongside their actual rewrite behaviour and the behaviour that you desire. Then we can better understand what it is that you are trying to do. Commented Jan 7, 2011 at 2:40
  • Apache response with: Not Found (404) Commented Jan 7, 2011 at 2:40
  • Hi Tomalak, How I dont know to make good format. At the time I am write, the preview so good format. please tell me how? Commented Jan 7, 2011 at 2:43
  • Hi, No code available on both handler.php and index.php than just echoing my debug message: echo 'debug'; an then exit. Thank for your help. Commented Jan 7, 2011 at 2:57

1 Answer 1

0

You are rewriteing to the same non-existant directory...

Rewriterule (.*) handler.php

So if i go to yourdomain.com/no/directory/exists/

it redirects me to yourdomain.com/no/directory/exists/handler.php

So no file/directory

use a rewrite base or use

Rewriterule (.*) /handler.php

if handler.php exists at yourdomain.com/handler.php

and you might want to add a QSA on to append the variables...

Rewriterule (.*) /handler.php [R,QSA,L]

** also added the R flag to update/show the reidrect url in the browsers as well as the L flag for last rule...

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, thanks. But the problem is not on the .htaccess. If i do request as per your example if ok. Problem is in the query http://../test/form_login/query=%2Ftest%2Findex.php%3Fpage%3Dform&. Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.