March 19, 201016 yr If you have set up mod rewrite in Apache or the IIS equivalent, you know it can be a pain. I think I may have found an alternative. The url looks like this: http://domain.com/?/this/is/a/clean/url Where 'this/is/a/clean/url' is the actual page path. The ? makes the server not look up 'folder path' and it also doesn't read it the page path as a url variable. I plan on using it as a backup for users who don't run clean urls with my CMS. Both ASP.net and PHP are able to retrieve that 'clean url' segment in the url request on the server side. I then strip off the page path and use it. For example in c# I do the following: String url_path = ""; String[] url_array = { }; if (Request.Url.ToString().Replace("?", "") != Request.Url.ToString()) { url_path = Request.Url.ToString().Replace("?/", "╚").Split('╚')[1]; url_array = url_path.Split('/'); } Does this make sense?
March 25, 201016 yr Author Rewriting URLs is very easy and am pretty sure all but the rubbish hosts don't support this option. Your method seems quite manual though and seems a really messy way of doing things. Most CMS's have the option to use normal (E.g. page.php?page=234234) urls instead of rewrtten ones. The idea here is to replace that default url (E.g. page.php?page=234234) with the 'clean url alternative'.
Create an account or sign in to comment