所有, 我的Zend框架應用程序的結構是這樣的:Zend的MVC - htaccess的重定向
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
我的Apache虛擬主機是這樣的:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /opt/lampp/htdocs/xampp/billingsystem
ServerName billingsystem
ErrorLog logs/billingsystem.localhost-error.log
CustomLog logs/billingsystem.localhost-access.log common
<directory /opt/lampp/htdocs/xampp/billingsystem>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
我的公用文件夾在.htaccess是這樣的:
RewriteEngine on
# The leading %{DOCUMENT_ROOT} is necessary when used in VirtualHost context
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
如果我瀏覽到http://billingsystem,它顯示apache導演y瀏覽器的路徑。如果我去http://billingsystem/public,應用程序將在網頁上執行代碼。是否可以創建或修改.htaccess文件,以便當用戶瀏覽到http://billingsystem時,它應該將瀏覽器重定向到http://billingsystem/public並執行代碼而不是顯示目錄結構?
另外,當他試圖通過瀏覽器訪問任何文件夾時,如何將用戶重定向到「公共」目錄?
基本上,DocumentRoot應該被移動到公共文件夾.. – 2010-02-03 17:41:54
請參閱我的文章中的目錄結構編輯。現在,我嘗試將設計文件夾移動到公用文件夾中。我的/ application/view/scripts文件夾中的header.phtml文件試圖使用/design/css/struct.css來訪問它。它不適用於我這種方式.. – Jake 2010-02-03 17:48:32
您是否像我的示例中那樣從重寫規則中刪除了「%{DOCUMENT_ROOT}」?另外,如果您將瀏覽器指向'http:// www.billingsystem/design/struct.css',會發生什麼樣的錯誤? – prodigitalson 2010-02-03 17:53:54