dhimok Posted April 13, 2007 Share Posted April 13, 2007 Hello everyone. Do you know a good advanced guide about mod_rewrite and friendly urls? I am using the code below in my .htaccess file. It works very well as long as I use one querystring. Sometimes I need to pass many values thru querystrings and the page gets vulnerable. Any one knows a good way doing this the urls I get are like: 1.html 2.html .. 5.html etc. Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)\.html$ index.php?c=$1[L] I dont know if I was clear enough but Thanks anyway Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 13, 2007 Share Posted April 13, 2007 can you give an example of what you are trying to do? I personally use this method (with a few mods)... http://www.alistapart.com/articles/succeed/ Quote Link to comment Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 Lets say that my friendly url looks like this: 12.html is it possible to ad ?action=something after that? 12.html?action=something Quote Link to comment Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 I have to pages index.php?c=books index.php?c=books&k=foreign How can use friendly urls so that both urls work? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 13, 2007 Share Posted April 13, 2007 well friendly urls are clear of ? = and & (and if you are strict - any non-alphanumeric bar '/') so what you want to achieve is something like http://www.yoursite.com/books/foreign that way you can use Options +FollowSymLinks RewriteEngine on RewriteRule !\.(gif|jpg|png|css)$ index.php [NC, L] then in your index.php $url = strip_tags($REQUEST_URI); $url_array = explode("/",$url); array_shift($url_array); $url[0] will be 'books' and $url[1] will be 'foreign'. use the resulting values of the array to control the flow of your scripts. so you can use something like switch($url[0]) { case 'films': // do film stuff. break; case 'plays': // do play stuff. break; case 'books': // do book stuff. break; default: // show home page. } Quote Link to comment Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 What If i want to use extension .html or any other one Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.