我在 localhost 中有一个使用缩短 URL 的站点
http://localhost/Portal/mysite/profile.php?id=1
到
http://localhost/Portal/mysite/profile/1/this_is_id
使用.htaccess
下面的
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([0-9]+)/.*$ /Portal/mysite/profile.php?id=$1 [QSA,L,NC]
但是,我需要将 URL 改为http://localhost/Portal/mysite/this_is_id
这都在 localhost 中,这就是为什么.com
没有出现,但是站点文件是mysite
所以,我尝试发送一个在我的mysite/index.php
tomysite/profile.php
中的链接,$id
但它不起作用。无论如何简单的建议就可以了,谢谢
更新
好的,我按照你们俩的要求做了,但这是将用户从索引页面发送到个人资料页面的功能,我不知道如何修改它,即使我已经按照你们俩的要求做了。
// sql query goes here.
foreach ($stmt as $row) {
$url = "/profile/$row[id]/".preg_replace('/[^a-zA-Z0-9-_]/', '-', $row['company']);
echo "<h4><a href=\"$url\" class=\"urln\">". substr($row['company'], 0,26)."</a></h4>
";
}
回声是链接,现在当我按下该链接时,它会带我到未找到的页面
更新 2
这是我的目录的图像,链接在 index.php 中,当点击它时,它会将我发送到 profile.php 所有上述文件都位于WAMP/www/Portal/mysite