我在设置httpd.conf或.htaccess文件时无法识别一台服务器上的多个zend框架站点.
对于开发,我只有一个服务器,我正在尝试设置站点,以便我可以访问它们,如localhost/app1,localhost/app2等.
所以现在,当我转到localhost/app1时,它确实成功重定向到localhost/app1/public/index.php,但是当我转到localhost/app1/index/index时,我得到了404.
这是我的vhosts文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/app1/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog logs/error.log
CustomLog logs/access.log common
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
这是来自/ var/www/app1目录的.htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ /app1/public/index.php [NC,R,L]
Run Code Online (Sandbox Code Playgroud)
如果我更改vhosts文件中的DocumentRoot行,DocumentRoot "/var/www/app1/public"那么app1可以正常工作,但我只能访问那个...在http:// localhost.这可能吗?我想要发生的是,如果/ var/www是文档根目录,那么如果我转到localhost/app1,那些请求需要重定向到localhost/app1/public/index.php,如果我转到localhost/app2那些请求需要重定向到localhost/app2/public/index.php.
我希望我能清楚地解释清楚,任何帮助都表示赞赏.
最后
我最喜欢Phil的解决方案,因为我不想更改我的本地hosts文件并使用ServerName指令.如果您为每个应用程序拥有一个单独的域名,那么在生产环境中会很好,但不适用于开发.
除此之外,当使用备用目录来提供Web内容时,我遇到了403禁止的问题.正如我所说,权限似乎是正确的问题是SE_Linux,并且文件的安全上下文没有设置为httpd_sys_content_t.我发布了我在这里找到的解决方案,因为它专门解决了这个问题.谢谢.