Php 重写我错过了什么?

Php 重写我错过了什么?,php,mysql,.htaccess,mod-rewrite,Php,Mysql,.htaccess,Mod Rewrite,我的.htaccess文件中有以下内容: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)/$ /index.php?p=$1 [L] 这会将url从 http://domain.com/index.php?p=101 到 这一切都很好。但是在我的index.php中,我有一段代码列出如下链接: //getting links $sqlLinks

我的.htaccess文件中有以下内容:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/$ /index.php?p=$1 [L]
这会将url从

http://domain.com/index.php?p=101

这一切都很好。但是在我的index.php中,我有一段代码列出如下链接:

//getting links
$sqlLinks = "SELECT pid, linkh1 FROM pages WHERE draft= '0' AND pid > 100 ORDER BY linkh1 ASC"; 

$query = mysqli_query($myConnection, $sqlLinks) or die (mysqli_error()); 
$Links = '';
while ($row = mysqli_fetch_array($query)) { 
    $pid = $row["pid"];
    $linklabel = $row["linkh1"];  

$Links .= '<li><a href="http://domain.com/index.php?p=' . $pid . '">' . $linklabel . '</a></li>>  
我不明白的是,如何使所有指向的链接自动显示为:

http://domain.com/101/  
http://domain.com/102/  
http://domain.com/103/  
etc...

.htaccess文件路由传入的请求

要重写传出链接,为什么不正确格式化

$Links .= '<li><a href="http://domain.com/' . $pid . '">' . $linklabel . '</a></li>' 
$Links.='
  • '
    htaccess文件路由传入的请求

    要重写传出链接,为什么不正确格式化

    $Links .= '<li><a href="http://domain.com/' . $pid . '">' . $linklabel . '</a></li>' 
    
    $Links.='
  • '
    mod rewrite只负责重写您的请求

    它与您在网站中输出的html代码无关

    有一些模块可以进行后期处理,但并不常见


    通常的方法是按照您希望的方式打印链接,mod rewrite只负责重写您的请求

    它与您在网站中输出的html代码无关

    有一些模块可以进行后期处理,但并不常见

    通常的方法是打印你的链接,就像你想要的那样

    $Links .= '<li><a href="http://domain.com/' . $pid . '">' . $linklabel . '</a></li>'