【问题标题】:Configuration problem in my production server in symfony我在 symfony 中的生产服务器中的配置问题
【发布时间】:2010-01-28 17:57:56
【问题描述】:

嗯,我有一个共享主机,但我没有 ssh 访问权限。问题是服务器结构和 symfony 结构...

服务器具有这种结构

错误/ 日志/ ... 网络/

在 web 目录中,我们可以加载 web 应用程序... symnfony 结构是..

应用程序/ .. 网络/

问题在于,如果我尝试访问我的域,我必须将 www.domainname.com/web/ 放入 symfony 项目的访问权限...。

1) 如果我尝试将所有 web symfony 内容复制到 web 目录,它会呈现第一页 ok(index.php) 但链接错误,因为它们是 www.domainame.com/moduleName/ 并且该目录不存在.. .

2)如果我在网络域目录中创建一个 .htacces 文件...当我输入 www.domainname.com 时,它会将我自动重定向到网络,但其他链接在他的 www.domainname.com/web/moduleName/方向

我只想要 www.domainname.com/moduleName/... 我该怎么做???

很紧急。

谢谢。

编辑1。这是我的 .htaccess 文件...

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ web/index.php [QSA,L]
</IfModule>

编辑2。另一个相关的问题

..
/web/
   app/
   ...
   web/
/blog/

如果我修改它,我会在访问我的 /blog/ 目录时遇到问题吗? 谢谢

【问题讨论】:

    标签: symfony1 config production


    【解决方案1】:

    .htaccess mod_rewrite

    【讨论】:

    • davidosomething...我已经编辑了我的帖子以向您展示我的 .htaccess 文件..我需要修改什么¿
    【解决方案2】:

    为了从 url 中删除 /web,您需要使用一个名为 mod_rewrite 的 apache 模块。像这样:

    Options +FollowSymLinks +ExecCGI
    
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      # uncomment the following line, if you are having trouble
      # getting no_script_name to work
      #RewriteBase /
    
      # we skip all files with .something
      #RewriteCond %{REQUEST_URI} \..+$
      #RewriteCond %{REQUEST_URI} !\.html$
      #RewriteRule .* - [L]
    
      # we check if the .html version is here (caching)
      RewriteRule ^$ index.html [QSA]
      RewriteRule ^([^.]+)$ $1.html [QSA]
      RewriteCond %{REQUEST_FILENAME} !-f
    
      # no, so we redirect to our front web controller
      RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    

    这方面的文档是here

    设置 symfony 的正确方法是使用指向 web 文件夹的虚拟主机。这将使用 web 文件夹作为您的根目录,因此您不会在 url 中看到它。

    【讨论】:

    • peter 它不能很好地工作,因为它会将我重定向到 Web 服务器模块.. 在我的 .htacces 文件(我编辑过的帖子)中,你可以看到什么对我有用......但只有当我把 www.domain .com 其他链接是... www.domain.com/web/module 我想删除 /web/
    • 我尝试做... $this->setWebDir($this->getRootDir().'/web');和你粘贴的代码,但它不起作用......我已经编辑了我的答案。谢谢
    • 最后我将 web(symfony) 内容复制到 web(server)。更改项目配置路线,它适用于 RewriteRule ^(.*)$ index.php [QSA,L] 谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    相关资源
    最近更新 更多