这是我的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>
它只重定向到本地主机,而不是将相同的重定向到当前页面。
不知道我错过了什么
我认为你想:如果文件或目录不退出,重定向
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/('d+)/$ $1/$2 [R=301,L]
我明白了。这不是htaccess或url重定向问题。这是JavaScript的问题。#用于jquery。我的功能不能正常工作。