Zend framework Zend MVC-htaccess重定向
全部,, 我的Zend framework应用程序结构如下:Zend framework Zend MVC-htaccess重定向,zend-framework,mod-rewrite,Zend Framework,Mod Rewrite,全部,, 我的Zend framework应用程序结构如下: billingsystem -application -design --css --struct.css --icons --styles --images --js --common --thirdparty -public --index.php --.htaccess -library -- Zend <
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
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>
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]
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
#Zend Rewrite Rules
RewriteRule ^(.*)$ /public/$1 [NC,L]
AddHandler php5-script .php
我的Apache VHost如下所示:
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
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>
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]
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
#Zend Rewrite Rules
RewriteRule ^(.*)$ /public/$1 [NC,L]
AddHandler php5-script .php
如果我浏览到,它会在浏览器上显示apache目录路径。如果转到,应用程序将执行网页上的代码。是否可以创建或修改.htaccess文件,这样当用户浏览到时,它应该将浏览器重定向到并执行代码,而不是显示目录结构
此外,当用户试图通过浏览器访问任何文件夹时,我如何将其重定向到“public”目录?要直接回答您的问题,您可以使用重写规则将
.htaccess
直接放在计费系统
文件夹中:
RewriteRule^(.*)$/public/$1[NC,L]
但是,您的设置应该更像以下内容:
文件系统
billingsystem
-application
-design
-public
--index.php
--.htaccess
-library
-- Zend
虚拟主机
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
DocumentRoot /opt/lampp/htdocs/xampp/billingsystem/public
ServerName billingsystem
ErrorLog logs/billingsystem.localhost-error.log
CustomLog logs/billingsystem.localhost-access.log common
<directory /opt/lampp/htdocs/xampp/billingsystem/public>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
现在剩下的问题是,我知道你的
design
目录中有一些东西需要能够通过网络访问。。。您能否详细说明design
中的目录结构,以便我们了解您需要做什么(如果有的话)才能正确访问其中包含的各种类型的文件?要直接回答您的问题,您可以使用重写规则将.htaccess
直接放在billingsystem
文件夹中:
RewriteRule^(.*)$/public/$1[NC,L]
但是,您的设置应该更像以下内容:
文件系统
billingsystem
-application
-design
-public
--index.php
--.htaccess
-library
-- Zend
虚拟主机
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
DocumentRoot /opt/lampp/htdocs/xampp/billingsystem/public
ServerName billingsystem
ErrorLog logs/billingsystem.localhost-error.log
CustomLog logs/billingsystem.localhost-access.log common
<directory /opt/lampp/htdocs/xampp/billingsystem/public>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
现在剩下的问题是,我知道你的
design
目录中有一些东西需要能够通过网络访问。。。你能详细说明一下design
中的目录结构吗,这样我们就可以知道你需要做什么(如果有的话)才能正确访问其中包含的各种类型的文件了?我刚刚在一个网站上讨论了类似的内容。我的解决方案是,我需要在域上使用两个.htaccess文件。一个在站点的根级别,另一个在public
文件夹中
因此,位于域根的一个如下所示:
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
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>
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]
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
#Zend Rewrite Rules
RewriteRule ^(.*)$ /public/$1 [NC,L]
AddHandler php5-script .php
这似乎可以很好地通过Zend框架实现所有内容的传输
希望这是有帮助的。
-利亚姆我刚刚在一个网站上经历了类似的事情。我的解决方案是,我需要在域上使用两个.htaccess文件。一个在站点的根级别,另一个在
public
文件夹中
因此,位于域根的一个如下所示:
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
<VirtualHost *:80>
ServerAdmin webmaster@billingsystem.localhost
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>
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]
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
#Zend Rewrite Rules
RewriteRule ^(.*)$ /public/$1 [NC,L]
AddHandler php5-script .php
这似乎可以很好地通过Zend框架实现所有内容的传输
希望这是有帮助的。
-利亚姆请参见我文章中的目录结构编辑。现在,我尝试将设计文件夹移动到公用文件夹中。。/application/view/scripts文件夹中的My header.phtml文件尝试使用/design/css/struct.css访问它。。这样对我不起作用..您是否像我的示例中那样从重写规则中删除了
%{DOCUMENT\u ROOT}
?如果将浏览器指向http://www.billingsystem/design/struct.css
您会遇到什么样的错误?如果您当前正在对css路径进行硬编码,您可能还需要使用baseUrl()
函数来生成该路径。是的..我按照您的建议删除了%{DOCUMENT\u ROOT}。当我像你建议的那样浏览css时,它会将我重定向到一个定制的错误控制器,告诉我页面找不到..好的,首先简单一点-你在修改VirtualHost后重新启动了Apache,对吗?/design/css/struct.css
的所有者、组及其各自的权限是否与/index.php
的相同?你是如何包括stylsheet的,你使用的代码是什么(例如,你是否使用headLink
帮助程序,硬编码整个标记,回显@import
指令等)?请参阅我文章中的目录结构编辑。现在,我尝试将设计文件夹移动到公用文件夹中。。/application/view/scripts文件夹中的My header.phtml文件尝试使用/design/css/struct.css访问它。。这样对我不起作用..您是否像我的示例中那样从重写规则中删除了%{DOCUMENT\u ROOT}
?如果将浏览器指向http://www.billingsystem/design/struct.css
您会遇到什么样的错误?如果您当前正在对css路径进行硬编码,您可能还需要使用baseUrl()
函数来生成该路径。是的..我按照您的建议删除了%{DOCUMENT\u ROOT}。当我像你建议的那样浏览css时,它会将我重定向到一个定制的错误控制器,告诉我页面找不到..好的,首先简单一点-你在修改VirtualHost后重新启动了Apache,对吗?/design/css/struct.css
的所有者、组及其各自的权限是否与/index.php
的相同?您是如何包括样式表的?您使用的代码是什么(即,您是否使用headLink
helper、硬编码整个标记、回显@import
指令等)?