Language – PHP
Why did I suddenly decide to create friendly Urls for AuthWare. I must tell the truth – I never really intended to. There was a stage at which I wanted to restructure it to utilise Apaches
I’ve always had this thing for not comprehending regular expressions. In fact I hardly ever use them except for my html to xhtml converter (I think the function is called
The only stuff this function hasn’t been able to do is exclude specific tags. I’m a very stubborn coder – which means I don’t look at others’ work until I’m convinced I’m stumped – or until I come up with mine.
mod_rewrite, I realised it would never work out – I have both IIS and Apache on my machine and I’ve configured both to run PHP. There are some users that use Windows out there and there was no way I could see them being excluded from using my system – because IIS obviously doesn’t support rewriting except you use some third-party tool. I then remembered trying to browse some web pages and adding slashes at the end – just some idleness on my part. Was there a way to get it out? Yes, I discovered – by using
$_SERVER['PATH_INFO']. I converted the ampersands (&) to slashes as well as the “?“. I created an array
$temp_array by splitting – using
I then created a new blank array – let’s call it
$_get. For every even index x in
$temp_array, I looped through
$temp_array, adding an array member to
$_get with key
$temp_array[x] and value
$temp_array[x+1]. Then I
After using that method, I discovered that my sessions were being set wrongly whenever I turned friendly urls on. The
PHPSESSID was being set wrongly. No secure information is stored in the sessions – just the current page so that AuthWare remembers the last page you were viewing when you log out. For example, for
index.php/mode/cat/action/viewsub/id/1, the cookie path is
index.php/mode/cat/action/viewsub/id/1 which isn’t what I had in mind. I guess I have two options
- Save everything in a MySQL database but that just increases traffic or
- Find some way of extracting the real path of the script and then setting a cookie each time.
Linux servers have a different way of interpreting $_SERVER[‘PATH_INFO’] as I found out after uploading and running
phpinfo() when my friendly urls wouldn’t work. I had to insert a check and strip
$_SERVER["REQUEST_URI"]. It’s currently running as expected.