【发布时间】:2015-12-13 23:34:24
【问题描述】:
我的网址是:http://www.website.com/profile.php?username=xyz
但我想改成这样:http://www.website.com/xyz
可以使用.htaccess吗?
我试过了,但它给了我:
内部错误。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule (.*) profile.php?username=$1
【问题讨论】:
-
你能显示你的规则吗(即使它不起作用)
-
RewriteBase 上的 RewriteEngine / RewriteCond %{REQUEST_FILENAME} ! -f RewriteCond %{REQUEST_FILENAME} ! -d RewriteRule (.*) profile.php?username=$1
-
这段代码看起来不错。当您收到 500(内部服务器错误)时,您能否检查您的 Apache error.log 以查看确切的错误。
-
[2015 年 9 月 17 日星期四 13:07:15.016904] [core:alert] [pid 2944:tid 840] [client ::1:59761] D:/wamp/www/website/.htaccess : RewriteCond: bad flag delimiters, referer: localhost/website/profile.php?username=xyz
标签: php html .htaccess url-rewriting