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
( $ Matches will contain all "parts" of the url in an array)/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 .htaccessOtherwise, 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)Use a whitelist , including files so you can be sure that any internal The file will not be able to load.
Comments
Post a Comment