0

我的 .htaccess 文件中有以下内容

    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php

    Options -Indexes


    # preserve bandwidth for PHP enabled servers
    <ifmodule mod_php4.c>
     php_value zlib.output_compression 16386
    </ifmodule>

    # For security reasons, Option followsymlinks cannot be overridden.
    #Options +FollowSymLinks
    Options +SymLinksIfOwnerMatch
    RewriteEngine On
    RewriteRule ^faq/?$ faq.php
    RewriteRule ^about/?$ about.php
    RewriteRule ^portfolio/(.*)$ portfolio.php?p=$1

            #Error Page___NOT found
    ErrorDocument 404 /notfound.php

我的作品集仅包含“名人”、“婚礼”和“工业”部分,即只有以下页面是有效的作品集:

    mysite.com/portfolio/celebrity
    mysite.com/portfolio/weddings
    mysite.com/portfolio/industrial

在某些情况下,我的“作品集”页面出现问题:当我访问时

    "mysite.com/portfolio/celebrity"
    "mysite.com/portfolio/weddings"
    "mysite.com/portfolio/industrial"

一切正常。但是,如果我访问

    "mysite.com/portfolio/celebrity/"
    "mysite.com/portfolio/weddings/"
    "mysite.com/portfolio/industrial/"

(注意尾部斜杠),Firefox 给我以下错误

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

我试过用

    RewriteRule ^portfolio/(.*)/?$ portfolio.php?p=$1

这也无济于事,并显示上述错误。

参观

    "mysite.com/portfolio/some-non-existent-portfolio"

或者

    "mysite.com/portfolio/some-non-existent-portfolio/"

不重定向到“notfound.php”

4

1 回答 1

3

好的,感谢这个网页: http ://www.phpfreaks.com/forums/index.php?topic=167839.0

我将相关行更改为

    RewriteRule ^portfolio/([a-zA-Z]+)/?$ portfolio.php?p=$1

现在一切正常,包括在访问的投资组合类型不存在时显示“notfound.php”。希望这可以帮助某人。

于 2012-03-04T10:44:25.360 回答