Php 为Zend应用程序设置vhost
我目前正在接管一个PHP Zend项目,在本地机器上的mamp中设置vhost时遇到了问题。我让它在一定程度上工作,这意味着它将进入索引页并执行一些PHP,但是没有任何链接工作,也没有找到rout文件夹文件(css、js和图像),这是我的一个痛苦。我以前从未与Zend合作过,所以我不知道自己是否遗漏了什么 这是我的vhost项目设置Php 为Zend应用程序设置vhost,php,zend-framework,zend-framework2,config,vhosts,Php,Zend Framework,Zend Framework2,Config,Vhosts,我目前正在接管一个PHP Zend项目,在本地机器上的mamp中设置vhost时遇到了问题。我让它在一定程度上工作,这意味着它将进入索引页并执行一些PHP,但是没有任何链接工作,也没有找到rout文件夹文件(css、js和图像),这是我的一个痛苦。我以前从未与Zend合作过,所以我不知道自己是否遗漏了什么 这是我的vhost项目设置 <VirtualHost *:80> DocumentRoot "/Users/john/Sites/application-website/publi
<VirtualHost *:80>
DocumentRoot "/Users/john/Sites/application-website/public/"
ServerName gc.dev
#RewriteEngine on
<Directory "/Users/john/Sites/application-website/public/">
DirectoryIndex index.php
AllowOverride All
Order deny,allow
Allow from All
</Directory>
我想,您需要在.htaccess文件中添加以下行
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [NC,L]
也就是说,用你的密码-
# Enable rewrite engine
RewriteEngine On
RewriteBase /
# 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]
# Redirect to www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule . http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Remove trailing slash
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)/$ http%1://%{HTTP_HOST}/$1 [R=301,L]
# Redirect index.php to /
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^index.php$ http%1://%{HTTP_HOST}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [NC,L]
<VirtualHost *:80>
DocumentRoot /Users/john/Sites/application-website/public
ServerName gc.dev
<Directory /Users/john/Sites/application-website/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
你能给我们看看公用目录中的.htaccess文件吗?你应该有一个你激活了mod_rewrite吗?运行
sudo a2enmod rewrite
我已经编辑了这个问题,这样你就可以看到htaccess文件的内容了。看这个:基本上是这样,但仍然没有变化。这做了一些事情,好像图像已经开始显示,但是所有的样式/脚本等仍然没有:我们在这里有一点进展,我已经解决了这个问题使用images/css/js的公用文件夹路由。现在唯一的问题是,当我单击“gc.dev/”的外侧,例如“gc.dev/blog/”时,它找不到任何东西。
<VirtualHost *:80>
DocumentRoot /Users/john/Sites/application-website/public
ServerName gc.dev
<Directory /Users/john/Sites/application-website/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
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_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]