【问题标题】:SEO Friendly Urls 500 Server ErrorSEO 友好 URL 500 服务器错误
【发布时间】:2013-07-11 20:37:47
【问题描述】:

我的 htcaccess 文件中有以下内容:

Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php # Remove .php from filename
RewriteRule ^profiles/([^/]+)\.php profiles.php?id=$1&%{QUERY_STRING} [L] # Pretty url for Profile page
RewriteRule ^crime/([^/]+)\.php crime.php?id=$1&%{QUERY_STRING} [L] # Pretty url for Crime page
RewriteRule ^edit_account/([^/]+)\.php edit_account.php?type=$1&%{QUERY_STRING} [L] # Pretty url for Edit Account Page

到目前为止,.php 部分将从文件中删除,但现在当我尝试使用配置文件页面时,通过以下 url:/profiles/1.php 或 /profiles/1,我得到一个 500 内部服务器错误。文件有什么问题吗?

【问题讨论】:

  • 检查你是否安装了 mod_rewrite。还要在 Apache 错误日志中查找错误详细信息
  • @Maks3w mod_rewrite 已安装,在错误日志中我得到:[Sat Jul 13 13:03:09 2013] [error] [client *] Request exceeded the limit of 10 internal redirects due to可能的配置错误。如有必要,使用“LimitInternalRecursion”增加限制。使用'LogLevel debug'获取回溯。,referer:/players_online.php
  • 现在我在所有页面上都有一个 500 内部服务器错误。
  • 您是否尝试清除缓存

标签: php friendly-url


【解决方案1】:

一旦你写了删除扩展的规则,你就不需要写.php

RewriteRule ^profiles/([^/]+) profiles.php?id=$1&%{QUERY_STRING} [L] #without .php

【讨论】:

    【解决方案2】:

    如果您在远程服务器上托管此网站,请询问他们是否阻止了 .htaccess。这发生在我身上,服务器管理员在没有引起注意的情况下停止了 .htaccess。

    【讨论】:

    • 当我在 htaccess 中有这个时它起作用了: RewriteRule ^profiles/([^/]+)\.php profiles.php?id=$1&%{QUERY_STRING} [L] RewriteRule ^crime /([^/]+)\.php crime.php?id=$1&%{QUERY_STRING} [L] RewriteRule ^edit_account/([^/]+)\.php edit_account.php?type=$1&%{ QUERY_STRING} [L] 并且认为删除所有文件的 .php 扩展名也可以删除,但是在我这样做之后它就停止了工作。
    猜你喜欢
    • 2018-12-17
    • 1970-01-01
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 1970-01-01
    • 2021-05-17
    相关资源
    最近更新 更多