eT` Posted February 23, 2011 Report Share Posted February 23, 2011 Tā, īsumā manai lapai ir saites ./a ./b etc. bet ir arī ./d/123 pašlaik .htaccess rewrite izskatās šādi: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?page=$1 [QSA,L] un PHP daļa: $page = $_GET["page"]; if(empty($page)) $page = 'index'; include_once('pages/'.$page.'.php'); bet dodoties uz saiti ./c/123 viņš mēģina includot failu /c/123.php, lai gan gribētos, lai vienkārši includo c.php un 123 padodcaur $_GET lai varu ar kvēriju izvilkt visu, ko vajag. tātad: index.php?page=gallery -- lapa.lv/gallery index.php?page=news&id=3 -- lapa.lv/news/3 kaut kas šāds nederētu - RewriteRule ^(.*)/(.*)/(.*)$ index.php?page=$1&$2=$3 [QSA,L] ? Jo var būt, ka saite ir index.php?page=users&name=useris -- lapa.lv/users/useris Quote Link to comment Share on other sites More sharing options...
codez Posted February 23, 2011 Report Share Posted February 23, 2011 Tavā variantā, tev vienkārši vajag to get sadalīt daļās pēc '/', izmantojot explode. Bet ieteiktu noteikti iepazīties ar web aplikācijas strukturēšanas paņēmieniem, izmantojot MVC paternu. http://php.lv/f/topic/16923-ka-izveidot-vienkarsu-routing-framework-u/ http://php.lv/f/topic/16923-ka-izveidot-vienkarsu-routing-framework-u/ Quote Link to comment Share on other sites More sharing options...
Kemito Posted February 23, 2011 Report Share Posted February 23, 2011 Var arī izmantot case, bet nu par tādu variantu šeit noliņčos :D Quote Link to comment Share on other sites More sharing options...
daGrevis Posted February 23, 2011 Report Share Posted February 23, 2011 Pirms MVC, Es, lai nebūtu "jāčakarējas", iekš ".htaccess" pievienoju... Options +FollowSymlinks RewriteEngine on RewriteRule ^([^\.]+)$ $1.php [NC,L] Un "URL'AS" bija smukas! ^^ Kaut cik (parametri nebija)... Tagad var foo.php piekļūt rakstot foo (bez .php). Quote Link to comment Share on other sites More sharing options...
eT` Posted February 23, 2011 Author Report Share Posted February 23, 2011 Paldies, codez MVC tutoriālis noderēja :) 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.