web hosting - URL rewriting in PHP without htaccess -


The website is running on a web host, where we do not have access to the .htaccess file. However, I want to re-url the URL for the URL's friendly URL.

The original URL for example

  www.example.com/file?q=name  

the expected URL

  www.example As other people said, just use the link like  /index.php/nice/looking/url . In the middle of the URL "index.php" may seem a bit awkward, but I do not think it is possible to look better without .htaccess 

Otherwise, you can contact someone from your hoster at /index.php You can also ask the URL to redirect so that you can handle the /index.php without rewriting the URL in your URL. / P>

Then you can find out which file can be included by using only a regex match.

 preg_match ('@ [/] {1} ([a-zA-Z0-9] +) @', $ _SERVER ["PATH_INFO"], $ matches)   ( $ Matches will contain all "parts" of the url in an array)  

Use a whitelist , including files so you can be sure that any internal The file will not be able to load.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -