开发者

.htaccess equivalent of baseurl?

I'm trying to install Symfony on a shared server and am attempting to duplicate the httpd.conf command:

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

I need to do so using .htaccess

The redirect portion was done in the root using the following:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^symfony.mysite.ca [nc]
rewriterule ^(.*)$ http://symfony.mysite.ca/web/$1 [r=301,nc] 

For the alias, I've tried using:

RewriteBase /

but no success.

The main issue is that the index.php file residing in the /web folder uses the /web path in its path to images and scripts. So instead of

href="/css/main.css"  //this would work

it uses

href="/web/css/main.css"  //this doesn't work, already in the /web/ directory!

Any ideas? Thanks!


You can use...

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

to prevent urls that refer to actual files from being rewritten, thus preventing the generic rewrite from adding a second /web into the URL.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜