apache 如何在php中使用url重写时删除内部服务器错误

hmae6n7t  于 2023-10-23  发布在  Apache
关注(0)|答案(2)|浏览(123)

我想重写我的URL:

http://www.example.com/mypage.php?unm=hr

重写后:

http://www.example.com/hr

htaccess文件:

RewriteEngine On
RewriteRule ^([^/]*)$ /myuser.php?url=$1 [L]

但它引发了一个错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 Server at localhost Port 80
hmmo2u0o

hmmo2u0o1#

你必须指定所有的JavaScript以及所有的css文件有fullpath一样,我们一般访问文件把一样

<link href="css/pygments-manni.css" rel="stylesheet">

现在你可以像这样使用。

<link href="<?php echo $path ?>css/pygments-manni.css" rel="stylesheet"> 
$path="http://".$_SERVER['HTTP_HOST']."/" ;
vlju58qv

vlju58qv2#

请确保以下事项:

  • mod_rewrite在apache配置中启用
  • 您可以通过在.htaccess中的任何规则或条件之前添加以下行来启用重写模块:

RewriteEngine On

相关问题