另一个.htaccess url重写问题


another .htaccess url rewriting issue

我有一个在wampserver上本地开发的网站,我正在.htaccess文件中使用url重写。我已经尝试了以下所有方法:

  1. mod_rewrite已启用
  2. httpd.conf对目录("C:''wamp''www''pascale3")具有AllowOverride All

这是我的.htaccess文件,它在这个目录("C:''wamp''www''pascale3")中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(about|mission|contact)/?$ index.php?p=$1
</IfModule>

这是我试图重写的url:

http://local.pascale3.com/?p=about

我还有一个godaddy直播网站,它在那里也不起作用

用以下代码替换.htaccess规则:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# to externally redirect /index.php?p=about to /about
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s/+(?:index'.php)?'?p=(about|mission|contact)[&'s] [NC]
RewriteRule ^ /%1? [R=301,L]
# to internally forward /about to /index.php?p=about
RewriteRule ^(about|mission|contact)/?$ /index.php?p=$1 [L,QSA,NC]

尝试这个index.php来调试

<?php
    echo('<pre>');
    print_r($_SERVER);
    print_r($_GET);
    die;

看看你是否得到了这样的东西,当去http://local.pascale3.com/contact

Array(
    ......
    [QUERY_STRING] => p=contact
    [REQUEST_URI] => /contact
    [SCRIPT_NAME] => /index.php
    [PHP_SELF] => /index.php
    [argv] => Array
        (
            [0] => p=contact
        )
    [argc] => 1
)
Array
(
    [p] => contact
)

如果您没有看到该p参数,则存在服务器配置/htaccess问题。还检查是否为index.php?p=接触完全有效。您可以看到上面的调试信息。