【问题标题】:Remove 'web' from Symfony 1.4 path on shared hosting?从共享主机上的 Symfony 1.4 路径中删除“网络”?
【发布时间】:2011-08-16 02:47:42
【问题描述】:

我发现了很多关于在共享主机计划中安装 Symfony 1.4 的有用信息,但是我遇到了一个让我困惑了一整天的绊脚石。

转到 http://www.alternium.net/jobeet/index.php 返回 404 而不是 http://www.alternium.net/jobeet/web/index.php 处的文件。

/jobeet/.htaccess:

Options +FollowSymLinks +ExecCGI

# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/robots.txt
RewriteRule ^(.*)$ /jobeet/web/robots.txt [L]

# resources
RewriteCond %{REQUEST_URI} ^/images/  [OR]
RewriteCond %{REQUEST_URI} ^/js/      [OR]
RewriteCond %{REQUEST_URI} ^/fonts/   [OR]
RewriteCond %{REQUEST_URI} ^/css/     
RewriteRule ^(.*)$ /jobeet/web/$1 [L]

RewriteCond %{REQUEST_URI} !^/jobeet/web/
RewriteCond %{REQUEST_URI} !^/frontend_dev.php
RewriteRule ^(.*)$ /jobeet/web/index.php/$1 [QSA,L]

RewriteCond %{REQUEST_URI} frontend_dev.php
RewriteRule ^$ /jobeet/web/$1 [QSA,L]

/jobeet/web/.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]

  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteCond %{REQUEST_URI} !\.php
  #RewriteCond %{REQUEST_URI} !\.php
  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>

谁能比我更了解 Symfony 或重写规则,告诉我哪里出错了?

【问题讨论】:

    标签: .htaccess mod-rewrite symfony1 symfony-1.4


    【解决方案1】:

    如果你的共享主机上有一个私人文件夹(比如在 plesk 主机上),你可以将所有 symfony 文件夹(除了 web/)放在你的私人文件夹中。然后你必须在 symfony 配置中调整你的 web 目录和你的前端控制器中 ProjectConfiguration 的路径(index.php 或 frontend_dev.php,...)。

    【讨论】:

    • 我知道这种抽象级别是可取的,但我们正处于时间紧迫的状态,虽然我确信这种配置对大多数人来说是不费吹灰之力,但我需要尽可能节省时间,所以对我来说,最简单的配置几乎在所有情况下都是最好的。
    • 这将是最简单的解决方案 - 需要几行代码来实现它。请参阅symfony-project.org/jobeet/1_4/Propel/en/… 移动 web 目录,然后相应地调整前端控制器中的 require 路径,以找到 Symfony 文件。
    猜你喜欢
    • 2019-04-07
    • 2011-08-13
    • 2017-06-28
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 2018-05-13
    • 1970-01-01
    相关资源
    最近更新 更多