.htaccess空页如果有多个请求

时间:2017-01-16 13:05:10

标签: php string .htaccess

下午好,

我有一个关于我的.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 个答案:

答案 0 :(得分:0)

我找出了为什么我得到了空白页面。存在冲突,因为它正在测试类别的相同单词。

## 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来说并不是个好主意。我该怎么办?谢谢。