我在.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
答案 0 :(得分:2)
您可以使用此规则:
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+))?/?$ index.php?nav=$1#$2 [L,QSA,NC]