mod_rewrite makes no sense to me

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

mod_rewrite makes no sense to me

Post by Benjamin »

I have tried about a million things that I thought should have worked to no avail. I'm playing around with the symfony framework trying to get things working the way I want.

I have a path /home/username/public_html/project/web/
The webroot is /home/username/public_html/

When I pull up http://localhost I get a list of projects that I am working on. Symfony places the files for a project inside of a subfolder.

So if I request http://localhost/projectname I get framework files instead of the website. Symfony documenation wants you to setup a virtual host for each project, which isn't something I want to do.

What I want is to transparently rewrite http://localhost/projectname to http://localhost/projectname/web. This should by very, very simple to do, but nothing I have tried works.

Here's what I've got:

/home/username/public_html/project/.htaccess

Code: Select all

 
Alias /sf /usr/share/php/data/symfony/web/sf
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !^web.* [NC]
RewriteRule ^(.*)$ web/$1 [L]
 
Also, how would I go about adding an Alias into this file? Apache complained..
/home/username/public_html/project/.htaccess: Alias not allowed here
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: mod_rewrite makes no sense to me

Post by Benjamin »

Ok, I don't think there is a way to make that work.. at least I haven't been able to fine one. I tried using:

Code: Select all

 
Alias /project_name /home/username/public_html/project_name/web
 
But ended up with a 500 error due to an endless redirect loop :(

So another solution is to redirect requests to a subfolder to a subdomain.

Can someone help me write a rewrite rule to place in /home/username/public_html/project_name/.htaccess that will redirect all requests from http://localhost/project_name/ to http://project_name.localhost/ please? I have tried but aren't having any luck.
Post Reply