【发布时间】:2015-08-05 15:37:22
【问题描述】:
这是我的 php 代码(qs.php)。该文件包含漂亮的 url 链接。
<html>
<head></head>
<body>
<?php
$file = 'qs1'; //this is a php file qs1.php
$id = '12345678'; //testing ID
$complete_url = $file."/".$id;
?>
<a href ="<?php echo $complete_url;?>"> This is a test link </a>
</body></html>
此链接出现链接此-http://localhost/qs1/12345678
QS1 是一个 php 文件 (qs1.php)。
QS1.php
<html>
<head>
<title>QS1 file</title>
</head>
<body>
<a href="#"><img src="images/blog/girl.png" class="img-circle" alt="" /></a>
<a href="#"><img src="images/blog/girl2.png" class="img-circle" alt="" /></a>
<a href="#"><img src="images/blog/girl3.png" class="img-circle" alt="" /></a>
</body></html>
下面是htaccess代码。
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/(\d+)/$ $1/$2 [R=301,L]
一切正常。我的链接工作正常。 http://localhost/qs1/12345678 链接可以通过这个访问。我能够访问该页面。在我使用此代码的当前页面中(#)。我可以说该页面上的其他链接。
<a href="#"><img src="images/blog/girl.png" class="img-circle" alt="" /></a>
它只重定向到本地主机,而不是将其传递到当前页面。
不知道我错过了什么。
【问题讨论】:
-
我放了一些qs1.php文件的html代码。
标签: php html .htaccess hyperlink url-rewriting