Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [mod_rewite][php] funkcja przepisujaca
wiiir
post
Post #1





Grupa: Zarejestrowani
Postów: 260
Pomógł: 34
Dołączył: 22.02.2010

Ostrzeżenie: (0%)
-----


heja.. znalazlem taka funkcje

  1. <?php
  2. function rewrite_url_filter($data)
  3. {
  4. $link = $data[0];
  5. $link = ereg_replace('"$', '', $link);
  6. $link = explode('="', $link);
  7. $_link = $link[0];
  8. $link = $link[1];
  9. //reguly
  10. //trzy zmienne
  11. $link=preg_replace('#index.php\?zmienna1=([0-9]*)&zmienna2=([0-9]*)&zmienna3=([0-9]*)#', 'index-\\1-\\2-\\3.htm',$link);
  12. //dwie zmienne
  13. $link=preg_replace('#index.php\?zmienna1=([0-9]*)&zmienna2=([0-9]*)#', 'index-\\1-\\2.htm',$link);
  14. //jedna zmienna
  15. $link=preg_replace('#index.php\?zmienna1=([0-9]*)#', 'index-\\1.htm',$link);
  16.  
  17. $link=preg_replace('#index.php#','index.htm',$link);
  18. $link=preg_replace('#index.php#','index.htm',$link);
  19.  
  20. $link=preg_replace('#index.php#','index.htm',$link);
  21. $link=preg_replace('#rewrite_test.php#','rewrite_test.htm',$link);
  22.  
  23. $link = $_link.'="'.$link.'"';
  24. return $link;
  25. }
  26. function rewrite_ob_filter($string)
  27.  
  28. {
  29. return preg_replace_callback('/(href|src|action)\s*=\s*"[^"]+"/', 'rewrite_url_filter', $string);
  30. }
  31.  
  32. ob_start('rewrite_ob_filter');
  33. ?>


nie jestem autorem wiec podaje link http://forum.sprawnymarketing.pl/pozycjono...zyjazne-url-22/

no i teraz pytenie... poniewaz zaczynam budowac nowy portal zastanawialem sie na "przyjaznymi linkami" ze wzgledu na pozycjonowanie, serwis bedzie dosyc rozbudowany wiec pomyslalem ze taki automat bylby dobry .. latwo mozna dodac nowe regoly, zmieniac postac linku z index-1-2-3-4-5.html na index/1/2/3/4/5/ itd itp
no i teraz pytanie czy warto cos takiego zastosowac (mi sie to podoba), albo czy macie podobne skrypty lepiej dzialajace z ktorymi moglibyscie sie podzielic
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 22:16