如何从url中删除参数时,使用动态href


how to remove parameters from url when using dynamic href?

使用

传递参数
$n=isset($_GET['page']) ? (int)$_GET['page'] : 0;
echo('<a href="?page='.($n+1).'">Next</a>');

因此url是:

home.php?page=2

如何删除参数&*.php文件名称从url或make

"home/browse/" ?

为什么不使用重写引擎通过。htaccess来避免它

<IfModule mod_rewrite.c>
Options +FollowSymLinks
#enter code here
IndexIgnore */*
# Turn on RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>

add .htaccess in root:

RewriteEngine

RewriteCond %{REQUEST_FILENAME} !-d

rewritecsecond %{REQUEST_FILENAME} !-f

rewritecsecond %{REQUEST_FILENAME} !-l

重写规则^(.+)$ index.php?MyVar = $ 1 (QSA L)

,您可以在代码中使用$_GET['MyVar'],例如:

$MyVar = isset($_GET['MyVar'])? $_GET['MyVar'] : 'Nop' ;
$Arr= explode('/',$MyVar)  ;