maasters Posted February 8, 2008 Report Share Posted February 8, 2008 Problēma ar mod_rewrite. Kods: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)$ ?category=$1&id=$2 [QSA,L] Ja es ierakstu mypage.com/users/1 tad man parādās kautkas. Bet ja ierakstu tikai mypage.com/users tad mod_rewrite nemaz nestrādā! Viņš rāda, ka nav direktorija vai fails. Kā atrisināt? Link to comment Share on other sites More sharing options...
Val Posted February 8, 2008 Report Share Posted February 8, 2008 (edited) RewriteRule ^(.*)$ ?category=$1 [QSA,L] ? pieraksti pie esošā .htaccess klāt :) Edited February 8, 2008 by Val Link to comment Share on other sites More sharing options...
maasters Posted February 8, 2008 Author Report Share Posted February 8, 2008 Bet man vajag lai strādā abi - gan users, gan users/1 Link to comment Share on other sites More sharing options...
marcis Posted February 9, 2008 Report Share Posted February 9, 2008 Nu un vaitad nestrādā, pieliekot jaunu Rule? Link to comment Share on other sites More sharing options...
maasters Posted February 10, 2008 Author Report Share Posted February 10, 2008 Tapēc jau arī rakstīju šeit. Pirms tam jau biju ko līdzīgu izmēģinājis. Kļūda visticamāk ir pierakstā, jo es tā īsti nepārzinu to rewrite sintaksi. Nu tad nu kods man sanāca tāds RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)$ ?category=$1&id=$2 [QSA,L] RewriteRule ^(.*)$ ?category=$1 [QSA,L] Un parādījās 500 Internal Server Error. Link to comment Share on other sites More sharing options...
Kristabs Posted February 10, 2008 Report Share Posted February 10, 2008 Izpildi phpinfo(); un paskaties, vai pie Loaded Modules ir mod_rewrite Link to comment Share on other sites More sharing options...
maasters Posted February 10, 2008 Author Report Share Posted February 10, 2008 Ir. Man taču viss gāja ar sākuma kodu (skat. pirmo postu), erroru rāda kopš tā brīža, kad pieliku papildus rule klāt. Link to comment Share on other sites More sharing options...
maasters Posted February 12, 2008 Author Report Share Posted February 12, 2008 Atvainojos par dubultpoustu, bet, bet, bet vai tiešām kāds palīdzēs? Link to comment Share on other sites More sharing options...
Kristabs Posted February 12, 2008 Report Share Posted February 12, 2008 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ?category=$1 [QSA] RewriteRule ^(.*)/(.*)$ ?category=$1&id=$2 [QSA,L] L ir Last rule. Link to comment Share on other sites More sharing options...
maasters Posted February 12, 2008 Author Report Share Posted February 12, 2008 Paldies, tagad vairs nerāda erroru, bet ir tāds mazs bugs. Es pārbaudei uzliku prosta print_r($_GET). Man uzrādās šādi rezultāti: Array ( [category] => users/5 [id] => 5 ) Links: http://lapa.lv/users/5 Kā varētu izlabot to bugu, lai category Neņemtu neko, kas ir pēc tās slīpsvītras? Link to comment Share on other sites More sharing options...
Kristabs Posted February 12, 2008 Report Share Posted February 12, 2008 Es izmantoju metodi, kad visu rakstu iekš $_GET['url'] un tad pats splitoju. site.com/1/2/3/4, kas paarraksta uz $_GET['url'] = 1/2/3/4 un tad, piemēram, list($cat,$catID,$var3,$var4) = explode("/",$_GET['url']); Link to comment Share on other sites More sharing options...
Recommended Posts