3

On the server I have the following structure:

public_html
    ->wp
    ->project
        ->app
        ->src
        ->web

Where wp is a wordpress website and project is a symfony2 applicatiomn. The intention is that www.domain.com/project gives me the symfony2 application, where all other urls (without /project) go to the wordpress site.

In order to achive this, I have the following htaccess files:

public_html:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

public_html/project:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{HTTP_HOST} ^project.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.project.com$
    RewriteCond %{REQUEST_URI} !^web/
    RewriteRule (.*)$ web [L]
</IfModule>

public_html/project/web:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

So my application works but there is a redirect to www.domain/com/project/web visible, and that is what I want to hide! Please advice as I seem to lack htaccess knowledge to achieve this.

1 Answer 1

1

If I understand your question right, you want to hide the word web from the URL of symfony app.

This is what I have in my .htaccess file to hide the web. I have this .htaccess file at the root of my symfony app, in your case it should be in project folder

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website.com/project$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.website.com/project$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
</IfModule>
Sign up to request clarification or add additional context in comments.

6 Comments

Well when I use example you give, it gives me a Wordpress error page, as /web gets me out of the project folder. So what I tried is: RewriteRule (.*) /project/web/$1 [L] or RewriteRule (.*) web/$1 [L] Both get me to the Symfony2 directory, and in my log file I get: "No route found for "GET /project/"" So somehow it never gets to the web directory....
did you try RewriteCond %{HTTP_HOST} ^website.com/project$ [NC,OR] and RewriteCond %{HTTP_HOST} ^www.website.com/project$ have a look at my updated answer
When I do that, I just get a directory listing of my project directory. What I do notice is that the request gets picked up by htaccess, but always seems to return /project/.
Okay one step further: the rewrte rules do get me towards the web directory it seems, but the only thing that Symfony gets is /project/, which of course leads to nothing. After all, the routing starts at /. Suppose I can add /project/ to my main routing, but that would mean I have to adapt stuff like FOSUser routing (as that uses /login for example). What I want is that Symfony only sees /
Wouldn't it be easier if you put your Symfony app in subdomain.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.