簡體   English   中英

htaccess和php_self在同一頁面中不起作用

[英]htaccess and php_self dont work in same page

因此,然后我使用php_self並按下一步按鈕進入index.php,但我想保留在單擊的頁面中。

所以我的.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

有這樣的規則:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM