Apache Symfony-Symlink到控制器以从Url中删除.php扩展名

Apache Symfony-Symlink到控制器以从Url中删除.php扩展名,apache,symfony1,nginx,Apache,Symfony1,Nginx,早上好,我已经处理这个问题好几天了,无法解决它 Http堆栈:nginx 1.0.4、apache 2.2.3、symfony 1.4.11 在我的web目录中,我有一个指向后端控制器的符号链接,因此我可以使用不带.php扩展名的URL,例如:mysite.com/be_dev.php=mysite.com/be_dev 在谷歌搜索之后,我注意到有很多方法可以做到这一点,但我发现最优雅的方法是将apache与ForceType指令一起使用。如果没有这个指令,当我在url中使用符号链接时,它只显示

早上好,我已经处理这个问题好几天了,无法解决它

Http堆栈:nginx 1.0.4、apache 2.2.3、symfony 1.4.11

在我的web目录中,我有一个指向后端控制器的符号链接,因此我可以使用不带.php扩展名的URL,例如:mysite.com/be_dev.php=mysite.com/be_dev

在谷歌搜索之后,我注意到有很多方法可以做到这一点,但我发现最优雅的方法是将apache与ForceType指令一起使用。如果没有这个指令,当我在url中使用符号链接时,它只显示php代码,但当我将ForceType指令放置到位时,它会按预期解析php

我现在遇到的一个问题是,当我通过符号链接时,它将符号链接视为webroot。所以文件是从/be_dev/sf/sf_web_debug/images/*vs/sf/sf_web_debug/images/*提供的。如果我通过be_dev.php,那么一切都会按预期进行

我已经尝试过各种重写规则来从路径中删除/be_dev,这样就可以从上面提到的/be_dev获得服务,但无法确定它

我正在发布配置文件的相关片段

提前谢谢

/usr/local/nginx/etc/nginx.conf

/etc/httpd/conf/vhost.d/10_symfony.conf

ForceType应用程序/x-httpd-php
/etc/httpd/conf/vhost.d/999_default.conf
listen3001
NameVirtualHost本地主机:3001
SetEnv服务类开发
SetEnv SERVICEAPP app1
ServerName myhost.*.mydomain.lan
ServerAlias myhost.*.mydomain.com
服务器管理员systems@mydomain.com
VirtualDocumentRoot/home/%2/projects/app/app1/current/code/web
不允许超限
选项如下符号链接
重新启动发动机
重写选项继承
#RewriteCond%{REQUEST_URI}^/be_dev/*[NC]
#重写规则^/be_dev/(.*)/$1[L,NC,PT]
#重写规则be_dev$/$1[L]
######
#Symfony规则
######
#如果遇到问题,请取消对以下行的注释
#无法使用脚本名称
#重写基/
#我们跳过了所有的文件
重写条件%{REQUEST_URI}\+$
重写条件%{REQUEST\u URI}!\。html$
重写规则。*-[L]
#我们检查.html版本是否在这里(缓存)
重写规则^$index.html[QSA]
重写规则^([^.]+)$$1.html[QSA]
重写cond%{REQUEST_FILENAME}-F
#不,所以我们重定向到前端web控制器
重写规则^(.*)$index.php[QSA,L]
重写规则/^(be_dev)$/$1.php[L]
######
日志级调试
CustomLog/var/log/httpd/app1.dev.access.log组合
ErrorLog/var/log/httpd/app1.dev.error.log
RewriteLog/var/log/httpd/app1.dev.rewrite.log
重写日志级别9
更新@6.13.2011 仍然没有运气弄明白这一点,任何帮助都是感激的

更新@6.15.2011
终于找到了!在我的博客上发布的@

终于找到了我无法从控制器中删除.php的原因,在深入研究之后,我发现我必须覆盖/apps//config/factories.yml文件中的“请求”设置。完整的答案可以在我的博客@上找到,下面给出了简短的答案

# /path/to/symfony/apps/<app>/config/factories.yml

# If you don't already have the following activated you will need to make sure it's active under the 'all' directive

all:

...

request:
  class: sfWebRequest # if you are using custom class be sure to replace this with your custom class name
  param:
    logging:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %SF_LOGGING_ENABLED%
    path_info_array:&nbsp;&nbsp; SERVER
    path_info_key:&nbsp;&nbsp;&nbsp;&nbsp; PATH_INFO
    relative_url_root: "" # <---This is what I needed to add

...
#/path/to/symfony/apps//config/factories.yml
#如果您尚未激活以下内容,则需要确保它在“all”指令下处于激活状态
全部:
...
请求:
class:sfWebRequest#如果使用自定义类,请确保将其替换为自定义类名
参数:
日志记录:%SF\u日志记录\u已启用%
路径信息数组:服务器
路径信息键:路径信息
相对url根目录:“#
<FilesMatch "^(fe|be)?(_dev)?$">
    ForceType application/x-httpd-php
</FilesMatch>
Listen 3001
NameVirtualHost localhost:3001

<VirtualHost localhost:3001>

    SetEnv SERVICECLASS dev
    SetEnv SERVICEAPP   app1

    ServerName     myhost.*.mydomain.lan
    ServerAlias    myhost.*.mydomain.com    

    ServerAdmin systems@mydomain.com

    VirtualDocumentRoot /home/%2/projects/app/app1/current/code/web

    <Directory "/home/*/projects/app/app1/current/code/web">
        AllowOverride none
        Options FollowSymLinks

        RewriteEngine on
        RewriteOptions inherit

        #RewriteCond %{REQUEST_URI} ^/be_dev/.* [NC]
        #RewriteRule ^/be_dev/(.*) /$1 [L,NC,PT]
        #RewriteRule be_dev$ /$1 [L]        

        ######
        # Symfony rules
        ######

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

        RewriteRule /^(be_dev)$ /$1.php [L]
        ######
    </Directory>

    LogLevel debug
    CustomLog /var/log/httpd/app1.dev.access.log combined
    ErrorLog /var/log/httpd/app1.dev.error.log
    RewriteLog /var/log/httpd/app1.dev.rewrite.log
    RewriteLogLevel 9

</VirtualHost>
# /path/to/symfony/apps/<app>/config/factories.yml

# If you don't already have the following activated you will need to make sure it's active under the 'all' directive

all:

...

request:
  class: sfWebRequest # if you are using custom class be sure to replace this with your custom class name
  param:
    logging:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %SF_LOGGING_ENABLED%
    path_info_array:&nbsp;&nbsp; SERVER
    path_info_key:&nbsp;&nbsp;&nbsp;&nbsp; PATH_INFO
    relative_url_root: "" # <---This is what I needed to add

...