簡體   English   中英

OSX + Apache2 + httpd.conf +主機+ .htaccess =不起作用

[英]OSX + Apache2 + httpd.conf + hosts + .htaccess = not working

在我的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(/庫/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,有什么想法嗎? 謝謝你們:-)

您必須在重寫規則中的站點名稱之后包含斜杠。 更改如下的重寫規則,然后嘗試:

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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM