简体   繁体   中英

how to remove parameters from url when using dynamic href?

passing parameters using

$n=isset($_GET['page']) ? (int)$_GET['page'] : 0;

echo('<a href="?page='.($n+1).'">Next</a>');

hence the url is:

home.php?page=2

how to remove parameters & *.php file name from url or make

"home/browse/" ?

why don't you use rewrite engine to avoid it by .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 On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?MyVar=$1 [QSA,L]

and you can user $_GET['MyVar'] in your code for examle:

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

after than you have on array of requst in array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM