Jump to content
php.lv forumi

mod_rewrite


hoho

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...