2011-05-11 62 views
2

我的Mac上,我试图激活本地PHP项目的htaccess重写规则。这里是我的配置:OSX + Apache2的httpd.conf文件+主机+ +的.htaccess =没有工作

我使用OSX 10.6.7,Apache2正在运行,Php5被激活。

我的项目位置:/资源库/ Web服务器/文件/我的项目/

的httpd.conf

[...] 
LoadModule rewrite_module libexec/apache2/mod_rewrite.so 
DocumentRoot "/Library/WebServer/Documents" 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
    Order deny,allow 
    Allow from all 
</Directory> 
<Directory "/Library/WebServer/Documents"> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 
[...] 

的httpd-vhosts.conf

NameVirtualHost *:80 
<VirtualHost *:80> 
    DocumentRoot "/Library/WebServer/Documents/my-project/" 
    ServerName my-project.local 
</VirtualHost> 

my_user_name.conf

<Directory "/Users/my_user_name/Sites/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 

主机

127.0.0.1 my-project.local 

* 的.htaccess(/Library/WebServer/Documents/my-project/.htaccess)*

Options +FollowSymLinks 
RewriteEngine on 
RewriteRule ^([0-9]+)\.home\.html$ front/content/home.php?rub=$1 
RewriteRule ^([0-9]+)-([0-9]+)-[a-z0-9A-Z'_%?éèàêâûô\-]+\.html$ front/content/article.php?id=$1&rub=$2 [L] 
[...] 

但是,当我尝试访问:

http://my-project.local/66-75-one-great-page.html

它不能解决为:

http://my-project.local/front/content/article.php?id=66&rub=75

Rhhaaa,任何想法? THX你们:-)

+0

** ** htaccess的:/Library/WebServer/Documents/my-project/.htaccess – 2011-05-12 20:08:52

+0

......并没有什么日志中的特殊。该死的!我只是不明白这一点...: -/THX你的答案... – 2011-05-12 20:21:49

+0

赞赏任何帮助...: - / – 2011-05-14 14:14:27

回答

0

你必须包括在重写规则站点名称后尾随斜线。更改重写规则如下,并尝试:

RewriteRule ^/([0-9]+)\.home\.html$ front/content/home.php?rub=$1 
RewriteRule ^/([0-9]+)-([0-9]+)-[a-z0-9A-Z'_%?éèàêâûô\-]+\.html$ front/content/article.php?id=$1&rub=$2 [L]