>  기사  >  백엔드 개발  >  关于PHP伪静态的有关问题

关于PHP伪静态的有关问题

WBOY
WBOY원래의
2016-06-13 10:20:411062검색

关于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, [email protected] 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,你可以自己写代码分析然后执行不同的代码

一些开源软件里都有相应的实现,可以参考

探讨

如果不修改Apache ,还可以实现这个功能吗?

------解决方案--------------------
探讨

如果不修改Apache ,还可以实现这个功能吗?

代码迷推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.daimami.com/java-web/317.html
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.