1
votes

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

1
Your formatting got busted in the post. Please try to format the sample .htaccess properly so that we can see it. - Lightness Races in Orbit
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. - Lightness Races in Orbit
Apache response with: Not Found (404) - Steve
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? - Steve
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. - Steve

1 Answers

0
votes

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...