I have the folowing in my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/$ /index.php?p=$1 [L]
this changes the url from
http://domain.com/index.php?p=101
to
http://domain.com/101/
This is all fine. But! In my index.php I have a piece of code to list the links like this:
//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>>
When I click or hover over a link it still shows the
http://domain.com/index.php?p=101 link.
What I don't understand is how can I make all links to automatically appear like:
http://domain.com/101/
http://domain.com/102/
http://domain.com/103/
etc...
The .htaccess file routes incoming requests.
To rewrite outgoing links, why not just format it properly?
$Links .= '<li><a href="http://domain.com/' . $pid . '">' . $linklabel . '</a></li>'
mod rewrite only takes care of rewriting your requests.
it has nothing to do with what html code you output in your website.
there are modules available that can do post processing and take care of that but they are veyr uncommon
the usual way is to print your links just as you would like them to have
精彩评论