Mod-rewrite URLs
Posted by 7Shadows • 490 Views • 17 Replies • FacebookTwitter
Posted by 7Shadows • 490 Views • 17 Replies • FacebookTwitter
impressive tutorial. now write a tut on everything you know about php.
Jun 27th, 2007so right now, the index.php?page=php&id=mod-rewrite-urls is the real url ?
Jun 27th, 2007yes exactly! you got it fast ;D
Jun 27th, 2007sweet, so, would you write a separate rule for each page you wanted to sexy-url-ify ? or just build your index.php around to just include pages based on $page ?
Jun 27th, 2007yep, with this method, it's about writing one index.php and include pages.
there are other ways and you can customize the codes, but i like it like that. at least, you got the basics of it!
yeah this way works for me too :) Usually how i do my sites anyways =D
Thanks a billion and 1 for this :) I can now have sexy URLS just like you :D
you're very welcome! i like it sexy and simple too. :D
Jun 27th, 2007keep your pants on, there cowboy!
Jun 27th, 2007pfft. a jealous one.
Jun 27th, 2007look at my face. Do I look jealous or need to be? :P
Jun 27th, 2007I tried that a few month ago.. back there it didn't work.
I should try it again w/ your tutorial :)
Ok, i got them to work -- but its cut off all access to my directories !! any idea how i get around that ?
Jul 1st, 2007i hope you coded links to your files as "/this/directory" or "http://www.domain.com/this/directory" instead of just "this/directory".
links like "this/directory" are still virtually like directories therefore, it thinks you're in that directory and call from that directory unless you specify the root or http.
yeah i always start at the root, if i dont, my shit gets broken and i get pissed off ! lol.
i just suck trying to read the mod_rewrite manual, so i did it like i posted on the other thread :/ Something i want to learn eventually for sure.
i couldn't figure that out either :/ which is why i posted the other thread about path info URLs
Jul 3rd, 2007
Rewriting your URLs to /thissexyurl instead of index.php?url=thissexyurl is quite simple:
Jun 27th, 20071) At the root of every server, you will find or you will have to create a .htaccess
2) In that file, put this code of mine:
ReWriteEngine On
#-------------------------------------------------------------------
# page/id/id2 instead of page.php?id=id&id2=id2
#-------------------------------------------------------------------
RewriteRule ^([a-zA-Z0-9_-]+)[/]?([a-zA-Z0-9_-]*)[/]?([a-zA-Z0-9_-]*)[/]?$ /index.php?page=$1&id=$2&id2=$3
3) What the codes mean is that every link separated by "/" will go to index.php
( Example: /page/id/id2 will go to index.php?page=page&id1=id1&id2=id2 )
Voila!