URL masking using php?

Hi,
I have a php file that displays a dynamic page at an url like www.mysite.com/somedirectory/somefile.php
For security reasons I would like to hide the directory and the file name in the url. So while the same page is displayed, the url should look like mysite.com/somepage.html
I found some suggestions using .htaccess file but none of them worked for me. Either the url is not changed or I get an 404 error.
Is threre a way to do this?

it’s called mod_rewrite. If it doesn’t work, you are using it wrong. But without knowledge of your environment and some code i see no way to help you.

Thank you. I don’t know what exactly you might need to know about my environment, will write what comes to my mind. Please let me know if you need to know anything else.
It’s a Joomla site but this particular php file runs outside Joomla. The php version 7 is used. I already have the .htaccess file and I use mode_rewrite for 301 redirects, that works without any problem.

Regarding the code, the file is called from another php file like this:

echo '<form action="../somedirectory/somefile.php" method="post"> <select name="choice">'; 
	.... some options here ...	
	echo '</select> <br /><input name="submit" value="Submit" type="submit" /> </form>';

Then, as I said, the URL displayed in the address bar is www.mysite.com/somedirectory/somefile.php

If you need more information can you please let me know what exactly

Sponsor our Newsletter | Privacy Policy | Terms of Service