.htaccess无法在localhost上工作

时间:2014-12-31 10:50:52

标签: .htaccess localhost mamp

我在.htaccess个文件中填写的完整代码:

Options FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule blue-world.pl/([a-z]+)(?:/([a-z]+))? index.php?nav=$1#$2

我需要将blue-world.pl/name/name2重定向到blue-world.pl?nav=name#name2。如何使其工作 BOTH :localhost和server。

在MAMP中我尝试输入:localhost/scregal.blue-world.pl/title我看到:

The requested URL /scregal.blue-world.pl/title was not found on this server.

以下是我在localhost中的文件层次结构:

scregal.blue-world.pl
    - .htaccess
    - index.php -> var_dump($_GET)

httpd.conf中有以下几行:

LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride All

1 个答案:

答案 0 :(得分:2)

您可以使用此规则:

Options FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+))?/?$ index.php?nav=$1#$2 [L,QSA,NC]