我使用 mac os x 10.6.8,但 mod_rewrite 有问题 - 它不起作用。
我在和中更改了 AllowOverride All。/etc/apache2/users/my_user.conf
/etc/apache2/httpd.conf
.htaccess 代码:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
PHP:
var_dump($_GET['q']);
结果:
Trying: http://localhost/~nonamez123/konkurs/asgfsddsh
Not Found
The requested URL /Users/nonamez123/Sites/konkurs/index.php was not found on this server.
如您所见,index.php
继续重写,但index.php
找不到
日志:
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (3) [perdir
/Users/nonamez123/Sites/konkurs/] strip per-dir prefix:
/Users/nonamez123/Sites/konkurs/asfdasdf - asfdasdf
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (3) [perdir
/Users/nonamez123/Sites/konkurs/] applying pattern '^(.*)$' to uri
'asfdasdf'
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (4) [perdir
/Users/nonamez123/Sites/konkurs/] RewriteCond:
input='/Users/nonamez123/Sites/konkurs/asfdasdf' pattern='!-f' =>
matched
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (4) [perdir
/Users/nonamez123/Sites/konkurs/] RewriteCond:
input='/Users/nonamez123/Sites/konkurs/asfdasdf' pattern='!-d' =>
matched
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (2) [perdir
/Users/nonamez123/Sites/konkurs/] rewrite 'asfdasdf' ->
'index.php?q=asfdasdf'
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (3) split
uri=index.php?q=asfdasdf - uri=index.php, args=q=asfdasdf
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (3) [perdir
/Users/nonamez123/Sites/konkurs/] add per-dir prefix: index.php ->
/Users/nonamez123/Sites/konkurs/index.php
127.0.0.1 - - [25/Sep/2012:21:06:13 +0300] [localhost/sid#10080d720][rid#1009d64a8/initial] (1) [perdir
/Users/nonamez123/Sites/konkurs/] internal redirect with
/Users/nonamez123/Sites/konkurs/index.php [INTERNAL REDIRECT]