2013-05-15 33 views
1

問題使用tutorial學習使用Zend框架重寫規則都在.htaccess的Windows(阿帕奇)

我可不是寫。我無法通過「確保.htaccess正在工作」部分。我知道有很多關於windows的問題,我會提到我所做的,以便我們可以在同一頁面中。

的.htaccess的內容如下:

RewriteEngine On 

# The following rule tells Apache that if the requested filename 
# exists, simply serve it. 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do 
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work 
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php [NC,L] 

總之,當我輸入網址\ fileDoesntExist和.htaccess規則應該抓住並將其轉換爲index.php文件。就這樣。

這是事情,它不是重寫所有的請求,給我一個404未找到的錯誤,我明白,因爲它正在尋找一個「fileDoesntExist」(顯然不存在)。當我查看該虛擬主機的錯誤日誌時,Get帖子是GET/fileDoesntExist ...這是錯誤的,因爲它應該是GET /index.php,因爲在.htaccess中放置了RewriteRule。

環境

視窗8 阿帕奇2.4

的httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so --> UNCOMMENTED 
AccessFilename htaccess --> (some have said that for Windows, it should be placed without the 
           leading dot) 
<Directory "C:\Apache24\hosts\zf2-tutorial\public"> 
    DirectoryIndex index.php 
    AllowOverride all 
    Order Deny,Allow 
    Allow from all 
    Options Indexes FollowSymLinks 
    Require all granted 
    RewriteRule ^(.*)$ index.php [NC,L] --> one user said that in windows if the rewriteRule is 
              not placed here, then it won´t take place. 
</Directory> 

想法試圖無濟於事

通過的phpinfo();我可以看到rewrite_module實際上已加載。 如果我刪除.htaccess裏面的內容,並把這樣的「aksdhfñashfña」(垃圾),我會得到一個「內部服務器錯誤」。

我不知道可能是什麼問題,幫助將非常感激,因爲花時間進行配置而不是開發非常令人沮喪。

按照De Morgan的法律,我試圖調整.htaccess的內容,以便它只關心何時找不到請求的頁面。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-s 
RewriteCond %{REQUEST_FILENAME} !-l 
Rewritecond %{REQUEST_FILENAME} !-d 
Rewritecond %{REQUEST_FILENAME} !-f 
RewriteRule ^.*$ index.php [NC,L] 

回答

2
  • 刪除AccessFilename指令(.htaccess默認情況下使用)
  • 更改<Directory>到(刪除所有的雜波)

    <Directory "C:/Apache24/hosts/zf2-tutorial/public"> <!-- forward slashes --> 
        Options Indexes FollowSymLinks 
        AllowOverride All 
        Order allow,deny <!-- Fix your order (allow first) --> 
        Allow from all 
    </Directory> 
    
  • 確保.htaccess位於DocumentRoot

+0

做了所有這些,結果相同。 :S – Chayemor

+0

我跳你也做了重啓。還要檢查你是否配置了'DocumentRoot「C:/Apache24/hosts/zf2-guide/ public」'。 –

+0

我做了一個重新啓動,得了偏執,甚至停下來,等了五分鐘,然後再次開始。是的,我有建議的DocumentRoot佈局。我放棄xD – Chayemor