在$“index”中,PHP $ _GET没有得到RewriteRule的值

时间:2013-03-20 23:04:00

标签: php html linux apache mod-rewrite

我遇到了问题。我正试图得到这个网址:

mySite.com/index.php?url=category/value1/value2/value3

由此:

MySite.com/category/value1/value2/value3

我有这个.htaccess文件:

<IfModule mod_rewrite.c>
RewriteEngine on

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

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
</IfModule>

如果类别只是“索引”,那么一切都正常,所以如果我把URL:

MySite.com/content/tv/color

数组$ _GET等于:

Array
(
    [url] => content/tv/color/
)

但是当我把:

MySite.com/index/option1/option2

数组为空

Array()

我检查了我的apache.conf文件但是我看不到问题。

<VirtualHost *:80>
        ServerAdmin user@site.com

        DocumentRoot /home/htdocs
        <Directory />
                AllowOverride all
        </Directory>
        <Directory /home/htdocs>
                #>>>>>HERE I HAVE MY TEST APP <<<<<<<<
                DirectoryIndex index.html index.php
                Options FollowSymLinks MultiViews
                RewriteEngine ON
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>
        Alias /simplesaml /var/simplesamlphp/www
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

1 个答案:

答案 0 :(得分:1)

您需要通过在MultiViews之前添加减号-来关闭-MultiViews选项。

实际上我不确定你为什么要明确地开启它。它只是一个配置复制粘贴吗?

此外,如果您不需要FollowSymLinks(我确定您不需要它),请将其关闭。