Home >Backend Development >PHP Tutorial >关于PHP伪静态的有关问题

关于PHP伪静态的有关问题

WBOY
WBOYOriginal
2016-06-13 10:20:411103browse

关于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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn