【问题标题】:.htaccess mod_rewrite giving 500 error.htaccess mod_rewrite 给出 500 错误
【发布时间】:2014-09-25 22:06:17
【问题描述】:

我有一个运行良好的 .htaccess 文件。但是,我刚刚将网站移至共享主机,一切都停止了工作。

这是我的 .htacces:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/preview/([^/]+)/?$ preview.php?c=$1&m=$2&i=$3 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/page/([^/]+)/?$ index.php?c=$1&m=$2&p=$3 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?c=$1&m=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?c=$1 [L]

我不能确定,但​​我认为问题在于托管帐户不在根级别。意思是我有一个域指向我的主机帐户,但是这个域 www.website.com 指向主机帐户上的 /website 文件夹。

错误信息只是:

Internal Server Error

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

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

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

Apache Server at crstrains.com Port 80

并且错误日志中没有生成任何内容。

我希望 www.website.com/Policies 与 www.website.com/index.php?c=Policies 相等,而且它曾经如此。不再。我该如何解决这个问题?

【问题讨论】:

  • 您是否尝试在RewriteEngine on 语句之后添加RewriteBase /website/stackoverflow.com/questions/704102/…
  • @KristerAndersson 我没有尝试过,但似乎没有帮助。我确实尝试修改 /([^/]+)s 的数量并让它抛出 404,说 /website/website/index.php 找不到...
  • @Prix 正如我在问题中所说,错误日志中没有生成任何内容。
  • @KristerAndersson 实际上,RewriteBase / 是我所需要的,这就成功了。
  • @sharf - 我将评论添加为简短回答 =)

标签: php apache .htaccess mod-rewrite


【解决方案1】:

您可以尝试添加 RewriteBase / 正好在下面 RewriteEngine On

【讨论】:

    【解决方案2】:

    您是否尝试在您的 RewriteEngine on 语句之后添加 RewriteBase /website/ 指令?

    结帐How does rewritebase work in .htaccess以了解有关如何使用RewriteBase的更多信息。

    【讨论】:

    • +1 你确实把我引向了正确的方向,但 Dipak 的回答在技术上对我来说是正确的,并且在你之前就进入了。
    • @sharf - 是的,我明白了 =)
    猜你喜欢
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-10
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    相关资源
    最近更新 更多