views:

40

answers:

3
+1  Q: 

Htaccess redirect

Hi, I'm trying to install a Symfony based website on a shared hosting server. I can write into /www/ only.

The problem is that Symfony will be in /www/web/ ; Is there a way to serve

www.example.com/web/index.php/something

when users ask for :

www.example.com/index.php/something
A: 

I've already tried

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/web/
RewriteRule .* /web/%1 [QSA]

And

RewriteEngine On
RewriteBase /web/
RewriteRule . /index.php [L]
Manu
A: 
RewriteCond %{REQUEST_URI} !/web/
RewriteRule ^(.*)$ /web/$1 [L]
Litso
+2  A: 

Try this rule in the .htaccess file in the document root directory:

RewriteEngine on
RewriteRule !^web/ web%{REQUEST_URI}

This will prepend /web to every request that’s path does not already start with /web/.

Gumbo
This works, but is there anyway to not add "/web/" to the url ? I'm redoing my website using symfony and I'd like to have the same urls as before, to keep my pagerank.
Manu
@Manu: This rule shouldn’t cause an external redirect. Are you using any other rules that may cause that?
Gumbo
I don't think so, I'll look.
Manu
@Manu: Take a look at [mod_rewrite’s logging feature](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteloglevel) to see what causes this external redirect.
Gumbo
Wow I don't think I can access that on the server
Manu
http://example.com/index.html serves /web/index.html, buthttp://example.com/test/ rewrites the url as http://example.com/web/test/I only have one htaccess file, maybe the server's config is weird.
Manu