2014-04-29 2 views
1

그렇다면 php_self를 사용하고 다음 버튼을 눌러 index.php로 이동하지만 클릭 한 페이지에 머물고 싶습니다. htaccess와 php_self가 같은 페이지에서 작동하지 않습니다

그래서 내 htaccess로 지금이 찾고 :

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /svetaine/ 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

테이블 페이지 매김 내 코드는 여기에 있습니다 :

<h1>Skaitmeniniai fotoaparatai</h1> 
<form method='get'> 
<?php 
//check if the starting row variable was passed in the URL or not 
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { 
//we give the value of the starting row to 0 because nothing was found in URL 
    $startrow = 0; 
//otherwise we take the value from the URL 
} else { 
$startrow = (int)$_GET['startrow']; 
} 
//this part goes after the checking of the $_GET var 
$fetch = mysql_query("SELECT * FROM sfotoaparatai order by rand() LIMIT $startrow, 20")or 
die(mysql_error()); 
$num=Mysql_num_rows($fetch); 
    if($num>0) 
    { 
    echo "<table border=2 >"; 
    echo "<tr><td>Prekes Pavadinimas</td><td>Kaina</td><td>Parduotuve</td> <td>Nuoroda</td></tr>"; 
    for($i=0;$i<$num;$i++) 
    { 
    $row=mysql_fetch_row($fetch); 
    echo "<tr>"; 
    echo"<td>$row[1]</td>"; 
    echo"<td>$row[2] LT</td>"; 
    echo"<td>$row[3]</td>"; 
    echo "<td><a href=\"{$row[4]}\"><img src=\"".base_url()."images/parduotuve.png\" /></a></td>"; 
    echo"</tr>"; 
    } 
    echo"</table>"; 
    } 
///now this is the link.. 
    echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+5).'">Sekantis</a>'; 

    $prev = $startrow - 5; 

//only print a "Previous" link if a "Next" was clicked 
if ($prev >= 0) 
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'"> Buves</a>'; 
?> 
</form> 
</body> 

후, 난 내 링크의 변화는 다음 테이블 페이지를 localhost로 클릭/svetaine/index.php? startrow = 5, localhost/svetaine/sfotoaparatai? startrow = 5

+0

현재 직면 한 문제는 무엇입니까? – anubhava

+0

이것은 테이블 페이지 매김이며, 이것은 한 페이지에 있어야하며, index.php로 리디렉션되고 싶지 않습니다. – Mangirdas

+0

여기서 리디렉션이 어디에서 발생하는지 보지 못합니까? 브라우저에서 어떤 URL을 원하십니까? – anubhava

답변

0

다음과 같은 규칙을 지켜야합니다.

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /svetaine/ 

RewriteCond %{QUERY_STRING} (^|&)startrow=[0-9] [NC] 
RewriteRule^- [L] 

RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
+0

동일합니다. PHP_SELF가 아닌 REQUEST_URI를 사용하는 것이 좋습니다. 그러나 문제는 이전 버튼에있을 것입니다. 다음은 올 바르게 작동합니다 – Mangirdas

+0

이 규칙은'startrow = [0-9] +'가 존재하는 한 재 작성을 피할 것입니다. (업데이트도 참조하십시오) – anubhava

+0

업데이트 질문. 어쩌면 내 테이블 페이지 매김이 아닌 다른 라인에 문제가있을 수 있습니까? 업데이트 된 질문을 시도했지만 여전히 문제가 있습니다. – Mangirdas