开发者

how to manage the use of both $_SERVER['PHP_SELF'] in action of form and htaccess for urlrewriting together for same page?

开发者 https://www.devze.com 2023-01-03 10:39 出处:网络
how to manage the use of both $_SERVER[\'PHP_SELF\'] in action of form and htaccess for url-rewriting?

how to manage the use of both $_SERVER['PHP_SELF'] in action of form and htaccess for url-rewriting?

If I submit a form and in the action attribute of it i pass "$_SERVER['PHP_SELF']" and at the same time i am using url rewriting for the same page.. then these two things will contradict each other resulting in the display of action value of form in address bar.. so how can i manage this to get the url rewrited form of $_SERVER['PHP_SELF']?

here the rewrite rule is to change the name of url file likewise as if form is submitted to any file say direction.php then rewrite will change it to som开发者_开发技巧ething 30/redirect.html


I am not sure what rewrite setup you have got so my guess is you have to specify the url in form action. You'd not be able to use $_SERVER['PHP_SELF'] as it will return the path of file which is actually being executed.

For example:

<form action="'.$_SERVER['PHP_SELF'].'">
to
<form action="'./url/as/per/rewrite'].'">

If this doesn't serve the purpose. You can have a look at $_SERVER['REQUEST_URI'] or

$_SERVER['REDIRECT_QUERY_STRING']
$_SERVER['REDIRECT_URL'] 

and update the form action value.

I hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消