[英]mod_rewrite returns file name as opposed to value
I'm try to create a clean URL turning http://www.example.com/view/index.php?id=12345
into http://www.example.com/view/12345
by adding the following to my .htaccess file: 我尝试通过将以下内容添加到来创建一个干净的URL,将
http://www.example.com/view/index.php?id=12345
转换为http://www.example.com/view/12345
。 htaccess文件:
RewriteEngine On
RewriteRule ^view/([^/]*)$ view/index.php?id=$1 [L]
This returns the file name index.php
as opposed to 12345
however. 这将返回文件名
index.php
,而不是12345
。 My error log is clear and I can't see what could be the issue here - any ideas? 我的错误日志很清楚,我看不到这里是什么问题-有什么想法吗?
You need a conditional match there 您需要一个条件匹配
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(?:GET|POST)\ /view/([^/\s?]+) [NC]
RewriteRule ^ view/index.php?id=%1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.