关于Snow Leopard的php简单mod_rewrite问题

时间:2011-12-12 22:07:50

标签: php mod-rewrite osx-snow-leopard

我的htaccess页面中有以下内容:

  <IfModule mod_rewrite.c>
   Options +FollowSymLinks
   RewriteEngine on
   RewriteRule (.*?)$
   index.php?page=$1
  </IfModule>

但这不起作用,并给我内部错误(500)。

但是如果我注释掉最后两行,页面加载确定不是错误但是没有达到我想要的效果。

 <IfModule mod_rewrite.c>
   Options +FollowSymLinks
   RewriteEngine on
   #RewriteRule (.*?)$
   #index.php?page=$1
  </IfModule>

任何想法可能是什么?

Mac Snow Leopard。 我的目录在DocumentRoot“/ Library / WebServer / Documents”中,我不使用普通http://localhost/~User/但是http://localhost/ ??等

由于

更新:

我已经回到这里,因为其他事情长期存在。所以请在下面找到我的新细节,这些细节我仍然会收到以下错误:

   Internal Server Error

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

   Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

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

我的网址:

  localhost/exp/index.php 

我的htaccess:

  RewriteEngine On
  RewriteRule (.*?)/(.*?)/(.*?)$
  exp/index.php?page=$1&action=$2&id=$3

不,我除了'RewriteEngine On'

之外我都会发表评论
  RewriteEngine On
  #RewriteRule (.*?)/(.*?)/(.*?)$
  #exp/index.php?page=$1&action=$2&id=$3

我收到了403禁止的消息。我会在页面加载中对它们进行评论。

我的/etc/apache2/httpd.conf文件详情如下:

 <Directory />
     Options Indexes MultiViews FollowSymlinks
     AllowOverride All
     Order allow,deny
     Allow from all
 </Directory>


 <Directory "/Library/WebServer/Documents/">
   Options Indexes MultiViews
   AllowOverride All
   Order allow,deny
   Allow from all
 </Directory>

我使用它作为我的localhost而不是我的用户localhost / ~User /

所以对我来说,生活中没有什么可以继续的。

2 个答案:

答案 0 :(得分:0)

# Turn on URL rewriting
RewriteEngine On

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php?page=URL
RewriteRule .* index.php?page=$0 [PT]

答案 1 :(得分:0)

答案来自这里: Answer to my question here

  RewriteEngine On
  RewriteRule ^(.*?)/(.*?)/(.*?)$ index.php?page=$1&action=$2&id=$3

似乎是休息,它需要在一条线上?