【问题标题】:php simple mod_rewrite issue on Snow Leopard雪豹上的 php 简单 mod_rewrite 问题
【发布时间】:2011-12-12 22:07:50
【问题描述】:

我的 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>

任何想法这可能是什么??

麦克雪豹。 我的目录在 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/~User/

所以我这辈子都不知道发生了什么事。

【问题讨论】:

  • 这可能会或可能不会,但只是注意到如果我只通过访问 localhost 列出我的目录,那么我正在使用的 efolder 不可见???在其他文件夹列表中

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


【解决方案1】:
# 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]

【讨论】:

  • 感谢您的回复,但是现在这会给我 403 禁止错误,并且该文件夹具有使用 get info 的所有读写权限? localhost/TestPages/index.php/test
  • @Simon Davies,好的,请尝试编辑版本。这应该适用于 Mac。确保 .htaccess 在 TestPages 文件夹中。
  • 感谢反馈,但仍然没有运气 403 禁止权限等,如果我删除 RewriteEngine On,那么页面就可以了,作为普通页面不是我想要的等等localhost/TestPages/index.php?page=newpage有效,但 localhost/TestPages/index.php/newpage 仍然无效。到目前为止谢谢
【解决方案2】:

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

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

似乎是休息时间,需要放在一条线上?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    相关资源
    最近更新 更多