0
我试图在共享服务器上安装Symfony和我试图复制在httpd.conf命令:.htaccess相当于baseurl?
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/sfproject/web"
DirectoryIndex index.php
<Directory "/home/sfproject/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfproject/lib/vendor/symfony/data/web/sf
<Directory "/home/sfproject/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
我必须这样做使用的.htaccess
重定向部分是在做根使用下列内容:
RewriteBase/
012:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^symfony.mysite.ca [nc]
rewriterule ^(.*)$ http://symfony.mysite.ca/web/$1 [r=301,nc]
为别名,我已经尝试使用
但没有成功。
主要问题是驻留在/ web文件夹中的index.php文件在图像和脚本路径中使用/ web路径。因此,而不是
href="/css/main.css" //this would work
它采用
href="/web/css/main.css" //this doesn't work, already in the /web/ directory!
任何想法?谢谢!
感谢您的提示,但我仍然有点困惑。我明白,我可以使用上面的示例来确定文件是否不存在。 我可以使用哪些RewriteRule: 1.检查查找文件的起始地址是/ web 2.用相同的路径替换该路径,但是将/ web从头开始切掉。 这可能吗? – 2010-04-01 03:01:43
'/ web/css/main.css'是*绝对*路径 - 即使它是从'/ web'目录中的文件引用的,因为它以'/'开始,它将相对于文档根加载,而不是其中的任何子目录。因此,我的猜测是,问题实际上并不需要从路径中移除*'/ web',而只是简单地防止您的重写过程*在已经指向正确文件的情况下添加它*以免触发。因此,我提出了一些条件,以防止在路径已经正确时触发重写过程。 – Amber 2010-04-01 03:28:59
谢谢!这清除了一切。 – 2010-04-01 12:36:23