dtlab08822 2014-08-13 15:15
浏览 49

为Zend应用程序设置vhost

I am currently taking over a PHP Zend project and i am having trouble setting the vhost up for it in mamp on my local machine. I have it working to an extent, meaning it going to the index page and executes some PHP, however non of the links are working nor is it finding the rout folder files (css, js and images) which is a pain in my backside. I have never worked with Zend before so i am unaware if i am missing something out.

Here is my vhost settings for the project...

<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>

If any one has any ideas it would be a great help, thank you in advance.

htaccess in public/

       # 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]

       RewriteRule ^(.*)$ index.php [NC,L]
  • 写回答

2条回答 默认 最新

  • duan19913 2014-08-13 18:45
    关注

    I guess, you need to add the following lines in your .htaccess file.

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [NC,L]
    

    That means, with your code -

    # 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]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分