开发者

Zend_View_Helper_Navigation_Menu creates an url I didn't expect

开发者 https://www.devze.com 2023-04-12 14:33 出处:网络
I used a small tutorial to create a menu through the Navigation_Menu view helper. I created my Zend folder inside a subfolder of localhost so now I can access this in my brwoser with

I used a small tutorial to create a menu through the Navigation_Menu view helper. I created my Zend folder inside a subfolder of localhost so now I can access this in my brwoser with

localhost/project/public

Now the menu gets a relative url from my config. For instance 'about' maps to /index/about.开发者_Go百科 Now my view helper maps 'about' to localhost/index/about. How can I map this to localhost/project/public/index/about without altering my config file?

Most probably, this is not Zend specific, so correct me if I'm wrong.


Assuming you are using Xampp/Apache lokal Webserver, here's the HowTo on setting up a local Domain

  1. Go to your $xamppRoot / apache / conf / extra Folder
  2. Inside that open http-vhosts.conf
  3. In the Top commented area, make sure to uncomment the following line NameVirtualHost *:80
  4. Now comes the variable part and i will just post my Structure. You may edit Servername (which basically is the url/domain), DocumentRoot (which is the path to project/public), SetEnv APPLICATION_ENV $yourenv (Zend Config Environment) and <Directory ...> (which once again is the path to project/public)

    <Virtualhost *:80>
      ServerName hod.dev
      DocumentRoot "C:\xampp\htdocs\prvt\cahod\public"
    
      SetEnv APPLICATION_ENV "local"
    
      <Directory C:\xampp\htdocs\prvt\cahod\public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
      </Directory>
    </VirtualHost>
    

With this your Apache now knows how to Set up a local domain. The only thing left to do now is to make your local machine not access the internet when accessing http://hod.dev

  1. Go to Windows / system32 / drivers / etc
  2. Open HOSTS (you may use a simple text editor)
  3. Inside this you'll see some lines already
  4. Just add 127.0.0.1 hod.dev
  5. Save it and have fun with your local domain

PS: I'm sorry that the code-block above does look shitty, but somehow it doesn't work really well in here - breaks the code somehow :(


Maybe you need to set or change the baseUrl parameter in your configuration file. Something like the following:

resources.frontController.baseUrl = "/project/public"

Hope that helps,

0

精彩评论

暂无评论...
验证码 换一张
取 消