hoho Posted October 14, 2014 Report Share Posted October 14, 2014 sveiki! palīdziet lūdzu ar mod_rewrite: Pašlaik projektā veidojas sekojoši linki : RewriteRule ^(en|lv)/(.*/)?([a-zA-Z0-9_-]+)(/)$ index.php?lang=$1&category=$3 [QSA,L] Tas ir: /lv/kategorija1/kategorija2/ utt. Man vajadzētu uztaisīt smukus nosaukumus ziņām, kuri būs tikai sadaļā "news": /lv/news/news-nosaukums/ un /en/news/news-nosaukums/ Kā uztaisīt lai ziņām tas "news-nosaukums" būtu cits mainīgais, "news_id" nevis "category" ? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted October 15, 2014 Report Share Posted October 15, 2014 A kas tev traucē iekš ziņu sadaļas uzskatīt, ka "category" ir ziņas nosaukums? Quote Link to comment Share on other sites More sharing options...
hoho Posted October 15, 2014 Author Report Share Posted October 15, 2014 Diemžēl tā nevar, jo sistēma ir uztaisītā savādāk. Vai nevar ar mod rewrite uztaisīt izņēmumu sadaļai "news" ? Quote Link to comment Share on other sites More sharing options...
jurchiks Posted October 16, 2014 Report Share Posted October 16, 2014 Izmanto šo: RewriteEngine on RewriteCond %{REQUEST_URI} !^/images/ RewriteCond %{REQUEST_URI} !^/css/ RewriteCond %{REQUEST_URI} !^/js/ RewriteCond %{REQUEST_URI} !robots.txt RewriteCond %{SCRIPT_FILENAME} !index.php RewriteRule .* ./index.php [L] Un apstrādā $_SERVER['REQUEST_URI'] kodā. Varēsi taisīt pilnīgi jebkādus urļus un nevajadzēs pisties ar htaccess. Quote Link to comment Share on other sites More sharing options...
Kavacky Posted October 16, 2014 Report Share Posted October 16, 2014 Gan jau, ka nevarēs, jo "tā nevar, jo sistēma ir uztaisītā savādāk". Quote Link to comment Share on other sites More sharing options...
jurchiks Posted October 16, 2014 Report Share Posted October 16, 2014 Slikti, ka tā. Quote Link to comment Share on other sites More sharing options...
Kasspars Posted October 16, 2014 Report Share Posted October 16, 2014 ^ Slikti, ka tu baigais gudrinieks, bet nevari puikam rewrite ruli uzrakstīt :D Šito ruli liec pirms tās category rules RewriteRule ^(en|lv)/news/?([a-zA-Z0-9_-]+)/?$ index.php?lang=$1&newsslug=$2 [QSA,L] Tagad $_GET['newsslug'] būs ziņas slug Quote Link to comment Share on other sites More sharing options...
jurchiks Posted October 16, 2014 Report Share Posted October 16, 2014 Nevis nevaru, bet negribu, jo var uztaisīt daudz labāk. 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.