2013-04-04 23 views
1

作爲一個經驗豐富的網頁開發人員,我覺得自己像一個白癡發佈這一點。不知何故,我傾向於與.htaccess有問題。我試圖路線中/wiki所有請求我的index.php與下面...無法獲得.htaccess的工作

RewriteEngine On 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ./ /index.php [L] 

當前虛擬主機:

<VirtualHost *:80> 
     ServerName mysite.local 
     DocumentRoot "/var/www/mysite/public_html" 
     <Directory "/var/www/mysite/public_html"> 
       Options Indexes FollowSymLinks MultiViews 
       AllowOverride All 
       Order allow,deny 
       allow from all 
     </Directory> 
</VirtualHost> 

我試圖訪問http://mysite.local/wiki/asdf並得到一個404錯誤。

Apache的錯誤日誌顯示什麼

回答

0

我最終需要什麼Yii框架使用...

RewriteEngine On 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 
0

如果/wiki是在你的public_html根文件夾中的現有文件夾,您index.php文件是wiki文件夾,然後你可以給以下嘗試:

RewriteEngine On 
RewriteBase /wiki 
RewriteRule index\.php - [F,L] 
RewriteCond %{REQUEST_URI} !-f 
RewriteCond %{REQUEST_URI} !-d 
RewriteRule .* index.php [L] 

如果wiki文件夾不存在,並且您正在完成根目錄下的所有工作:

RewriteEngine On 
RewriteBase/
RewriteRule index\.php - [F,L] 
RewriteCond %{REQUEST_URI} !-f 
RewriteCond %{REQUEST_URI} !-d 
RewriteRule wiki/(.*) index.php/$1 [L] 
0

現在試試這個吧!要重寫不存在/wiki/wiki//wiki/$var/index.php

RewriteCond %{REQUEST_URI} ^/wiki/? 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*) /index.php 
+0

我想只有改寫目錄/路徑,唐不存在,這就是爲什麼我認爲使用Wordpress'.htaccess會做到這一點。 – Webnet 2013-04-04 13:08:34

+0

哪些不存在,目錄或文件? – 5ervant 2013-04-04 13:13:57