URL rewriting in PHP without htaccess

website is running on a web hosting where we don't have access on htaccess file. i want to do URL rewriting for user friendly URL. e.g. Original URL www.domain-name.com/file?q=name

expected URL www.domain-name.com/file/name

Answers


As other people said, just use links like /index.php/nice/looking/url. The "index.php" in the middle of the URL might look a little strange, but I don't think it's possible to have it look better without .htaccess

Else, you could ask your hoster to redirect any URL to /index.php so that you can handle URL rewriting without having /index.php in your URL.

Then you can just use a regex match to detect what file to include. preg_match('@[/]{1}([a-zA-Z0-9]+)@', $_SERVER["PATH_INFO"], $matches) ($matches will contain all "parts" of the url in an array)

Be careful with including the files, use a whitelist so you're sure nobody would be able to load internal files.


Need Your Help

How to export a variable from a module in JavaScript?

javascript node.js variables module

According to this post we know that variables can be exported from one module in JavaScript:

Guidelines to support multiscreen android layout

android android-layout layout

I am currently working on an Android app. I am not an UI guy, and just trying out which number fits the best when I make the layout xmls like below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.