Delfins Posted December 4, 2006 Report Share Posted December 4, 2006 Nu bet tur jau tā lieta...!! tags `BASE` palīdz browserim izveidot pareizu URL. Val, cik reizes tev jāiesit pa galvu, lai tu beidzot saprastu... Link to comment Share on other sites More sharing options...
hmnc Posted December 4, 2006 Report Share Posted December 4, 2006 <?php define('base','/path/to/base/wwwdir/'); ?> <img src="<?=base;?>bilde.jpg" /> <style type="text/css"> @import '<?=base;?>style.css'; </style> .... Link to comment Share on other sites More sharing options...
Val Posted December 4, 2006 Report Share Posted December 4, 2006 (edited) Man bija savādāk. php: $dir = '/eee/'; html: .... <link rel="stylesheet" href="<?=$dir;?>style.css" /> Edited December 4, 2006 by Val Link to comment Share on other sites More sharing options...
hmnc Posted December 4, 2006 Report Share Posted December 4, 2006 nu kaut vai! vienīgi kāpēc define ir labāks: defined - definētais lielums, resp. sistēmā nav paredzēts lai šis mainās. $var - variable, mainīgais... attiecīgi. un smukāk arī izskatās <?=dir;?> :) Link to comment Share on other sites More sharing options...
Val Posted December 4, 2006 Report Share Posted December 4, 2006 Par to es galīgi nestrīdos. Vai tiešām nav vienkāršāk pārrakstīt url'as ar slašu beigās uz tādām bez? Link to comment Share on other sites More sharing options...
hmnc Posted December 4, 2006 Report Share Posted December 4, 2006 nesapratu jautājumu? un vispār ģenerē urlus ar funkciju - tad jebkurā brīdī varēsi switchot uz jebkāda veida urlēšanas sistēmu Link to comment Share on other sites More sharing options...
Val Posted December 4, 2006 Report Share Posted December 4, 2006 domāju ar mod_rewrite Link to comment Share on other sites More sharing options...
Delfins Posted December 4, 2006 Report Share Posted December 4, 2006 mod_rewrite pārraksta URL tikai pie pieprasījuma... tam nav nekāda daļas gar tavu līko kodu... kad browsers no tā `izrēķina` nepariezu URL un tālāk mēģina dabūt CSS tur, kur tas nemaz nav... Link to comment Share on other sites More sharing options...
Val Posted December 4, 2006 Report Share Posted December 4, 2006 (edited) Uztaisīju vēl mazliet līko kodu ;) <?php $server_name = $_SERVER["SERVER_NAME"]; $request_uri = $_SERVER["REQUEST_URI"]; $url = 'http://'.$server_name.$request_uri; $skaits = substr_count($request_uri, '/'); $slash = substr($request_uri, -1, 1); if(($slash == '/') && ($skaits>2)) { $url = substr($url, 0, -1); if(!headers_sent()) { header("Location: $url"); //echo $url; }; }; ?> pārāk nenolieciet... nākamreiz taisīšu kā vajag Edited December 4, 2006 by Val Link to comment Share on other sites More sharing options...
Val Posted December 5, 2006 Report Share Posted December 5, 2006 Options +FollowSymLinks RewriteEngine On RewriteRule ^.htaccess$ - [F] # RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.+)/$ /eeee/$1 [R=301,L] # RewriteCond %{REQUEST_URI} !\.(css|js|jpg|gif|jpeg)$ [NC] RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ index.php?id=$1 [QSA,L] Link to comment Share on other sites More sharing options...
Val Posted January 18, 2007 Report Share Posted January 18, 2007 (edited) Maza probl�“miņa ar rewrite... Ir lapa. Piem�“ram lapai vairākas sadaļas ($_GET mainīgais m) Katrai lapai padodamo parametru skaits var atšķirties, bet var arī sakrist - piem. /?m=1&x=2&y=3 /?m=2&z=6 /?m=3 Parametru nosaukumi arī katrā savādāki. Kādā veidā var katrai sadaļai uzrakstīt savu rewrite rule? Tādu lietu, kā rewritecond neizpratu Edited January 18, 2007 by Val Link to comment Share on other sites More sharing options...
hmnc Posted January 18, 2007 Report Share Posted January 18, 2007 ar cirvi!!!!! Delfinam bija viens ļoti labs piemērs savulaik kkur iemests šepat forumā. pēc pielāgošanas tavām vajadzībām ir ļoti ērti lietojams tūlis Link to comment Share on other sites More sharing options...
hmnc Posted January 18, 2007 Report Share Posted January 18, 2007 .htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?request=$1 [QSA] un vairāk tev NEKO NEVAJAG! pēctam apstrādā tikai visu pareizi! Link to comment Share on other sites More sharing options...
Val Posted January 18, 2007 Report Share Posted January 18, 2007 hmnc: Shis te? http://php.lv/f/index.php?showtopic=4055&a...amp;#entry32742 Link to comment Share on other sites More sharing options...
Kristabs Posted January 18, 2007 Report Share Posted January 18, 2007 Yes, tas pats. Būtībā pietiek ar hmnc minēto rewrite ruli un tad jau tālāk saskaldīt $_GET['request'] katrs pa savam var. Link to comment Share on other sites More sharing options...
Recommended Posts