Jump to content
php.lv forumi

Recommended Posts

Posted

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" ?

Posted

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.

Posted

^ 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...