OSX +阿帕奇2 + httpd.conf +主机 + .htaccess = 不工作
在我的 Mac 上,我尝试在本地 php 项目上激活 htaccess 重写规则。这是我的配置:
我使用 OSX 10.6.7,Apache2 正在运行,Php5 已激活。
我的项目位置:/Library/WebServer/Documents/my-project/
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,有什么想法吗? 谢谢你们:-)
On my Mac, I'm trying to activate htaccess rewrite rules on a local php project. Here's my configuration :
I'm using OSX 10.6.7, Apache2 is running, Php5 is activated.
My project location: /Library/WebServer/Documents/my-project/
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>
hosts
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]
[...]
But, when I try to access :
http://my-project.local/66-75-one-great-page.html
It don't resolve as :
http://my-project.local/front/content/article.php?id=66&rub=75
Rhhaaa, any ideas ?
Thx you guys :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在重写规则中的站点名称后面包含尾部斜杠。更改重写规则如下并尝试:
You have to include the trailing slash after the site name in rewrite rule. Change the rewrite rule as below and try :