Dynamic form action bath

I have a form at a php file that will be include at several php scripts, so the action php script will change related to the folder of other php scripts.
I am trying to pass the $rpath= ‘…/’ (relative path to the folder of the action script)
but when I write <form action=“<?php echo $rpath ?>/path/action.php” the $rpath is not writing.
I try to write the dirname(FILE) (the action php is at the same file of form php) but there is also the url of the site (site/c://…)
How can I solve this problem?

Post your code

I mange to pass the path ‘/…’ as the page that include the file is


and the form is


sto the form action is


But now the error is The requested URL was not found on this server.
What can I do?

I also use this htaccess, also the absolute path (http://…) of the action script go to the index.php

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
#RewriteBase /

#AuthName "Restricted Area" 
#AuthType Basic 
#AuthUserFile c:/xampp/htdocs/antenna/.htpasswd 
#AuthGroupFile /dev/null 
#require valid-user

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

#Rewriterule  ([^/]+)$  index\\.php/$1 [L]
RewriteRule ^(([^/]+)*)  index\\.php/$1 [L] 
#RewriteRule . index.php ^localpath(.*) otherpath$1 
#RewriteRule ^.*$ /index.php [L]
#RewriteRule . /index.php [L]
#RewriteRule ^([a-zA-Z0-9]+)/$  /index.php [L]

Use form action=“/modules/guest/guestbook.php” instead of action=“/…/modules/guest/guestbook.php”

Thanks so much for the tutorial. I followed it step by step.

Just want to share:
Using relative paths creates problem most of the times.
I simply use ABSOLUTE path by defining in some constant and has never get such issues of relativity problems.