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 Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/ 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/ Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/#findComment-228349 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 Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/#findComment-228350 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? Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/#findComment-228368 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. } Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/#findComment-228382 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 Link to comment https://forums.phpfreaks.com/topic/46850-friendly-urls-and-htaccess/#findComment-228387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.