【发布时间】:2016-06-28 18:01:58
【问题描述】:
我正在尝试从 yourwebsite/profile.php?username=funusername 制作我的网址 yourwebsite/funusername。我试过 .htaccess 之类的:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^/([^/]+)$ profile.php?username=$1
(我也有代码可以将.php 从我的页面中删除)。我对 .htaccess 非常缺乏经验,因此非常感谢任何帮助。
奖励:如何在链接中引用此 URL?如<a href="profileurl">
【问题讨论】:
-
我在整个互联网上搜索了一个解决方案,但要么没有任何东西对我有用,要么我找不到完整的代码示例。
-
是的,但我在链接中使用 PHP 变量。
-
好的,但是为什么一般的 .htacces 代码不起作用?
标签: php