关于PHP伪静态的问题!
我的.htaccess 这么写:
RewriteEngine on
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index.php?action=$1&id=$2
程序代码:
echo '你的Action是:' . $_GET['action'];
echo "
";
echo '你的ID是:' . $_GET['id'];
?>
现在在浏览器中输入:
localhost/page-18.html
但是报错:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
请问怎么解决?
------解决方案--------------------
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index.php?action=$1&id=$2
index.php前应该有空格
------解决方案--------------------
这有啥为什么啊,
rewriteRule要有原来的url和转去的url,你没空格,apache分不清啊,只好发疯500了
------解决方案--------------------
.htaccess就是apache的功能,不修改.conf不能生效, 不过现在大部分地方都是缺省就启用它
如果你是问能否在php里实现url分析及路由,Print_r你的$_SERVER, 里面有几个变量包含
完整的url,你可以自己写代码分析然后执行不同的代码
一些开源软件里都有相应的实现,可以参考