[英]htaccess rewrite example.com/user.php?id=username to example.com/username
Title says it all im having trouble rewriting the following urls 标题说,所有这些都无法重写以下网址
The original URL: example.com/user.php?id=username
原始网址: example.com/user.php?id=username
The rewritten URL: example.com/username
重写的URL: example.com/username
My .htcacess
code is: 我的.htcacess
代码是:
RewriteEngine On
RewriteRule ^([^/]*)$ /user.php?id=$1 [L]
What the issue? 什么问题
The rewrite engine will loop, which means the rewritten URI ( /user.php
) matches the same pattern and gets applied again. 重写引擎将循环,这意味着重写的URI( /user.php
)匹配相同的模式并再次应用。 Try adding some conditions: 尝试添加一些条件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /user.php?id=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.