【问题标题】:.htaccess empty page if mutiple request.htaccess 多个请求的空页面
【发布时间】:2017-01-16 13:05:10
【问题描述】:

下午好,

我有一个关于 .htaccess 文件的问题,该文件位于 ery 文件夹的根目录中。

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteBase /ery/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^menu/contact/?$ contact.php [NC,L]
RewriteRule ^events/(.+)$ events.php?events=$1 [NC,L]
RewriteRule ^menu/(.+)$ navigation.php?page=$1 [NC,L]

## request example - http://localhost/ery/categories/activities
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^categories/(.+)?$ categories.php?categories=$1 [NC,L]

## request example - http://localhost/ery/categories/activities/activities-for-care
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^categories/([^/]+)/([^/]+)$ categories.php?categories=$1&article=$2 [NC]

当我点击链接http://localhost/ery/categories/activities/activities-for-care 时,我得到了空白页面。我认为对 sql 的请求不正确,但我该如何解决?感谢您的帮助。

【问题讨论】:

  • 1. 您不需要在每个文件夹中放置相同的 .htaccess。将它放在根文件夹中就足够了。 2. 您可以删除所有RewriteCond ... !-f!-d,只保留第一对。 3. 您检查过错误日志吗?当display_errors 关闭时,通常会出现空页面。
  • ery 是文件夹的名称。只有一个 .htaccess 文件
  • 但是我感觉请求.htaccess的字符串不是正确编译器,因为activity-for-care是字符串。
  • 对不起。将“ery 文件夹”误读为“每个文件夹”:) 但您可以查看我提出的其他要点。特别是关于检查错误日志的内容。没有这个,我们所能做的就是猜测。

标签: php string .htaccess


【解决方案1】:

我找到了空白页的原因。存在冲突,因为它正在测试 categories 的同一个词。

## request example - http://localhost/ery/categories/activities/
RewriteRule ^categories/(.+)?$ categories.php?categories=$1 [NC,L]

## request example - http://localhost/ery/categories/activities/activities-for-care/
RewriteRule ^categories/([^/]+)/([^/]+)/$ categories.php?categories=$1&article=$2 [NC,L]

如果我像这样接受第二条规则

## request example - http://localhost/ery/category/activities/activities-for-care/
RewriteRule ^category/([^/]+)/([^/]+)/$ categories.php?categories=$1&article=$2 [NC,L]

然后我得到页面的结果。但我想这对于 SEO 来说并不是一个好主意。我该怎么做才能正确?谢谢。

【讨论】:

    猜你喜欢
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多