0

I'm using IIS7.5. Root directory is mapped to a path 'wwwroot', under which I have directories containing individual websites.

Just started working through the documentation for Symfony 2. The symfony site is under a folder called 'Symfony', ie 'wwwroot/symfony'.

I can access a path on this site using url: symfony/web/controller/param

How can i get rid of the 'web' part so it is: symfony/controller/param?

Here is relevant part of web.config:

<rule name="RewriteRequestsToPublic" stopProcessing="true">
   <match url="^(web/)(.*)$" />
   <action type="Rewrite" url="web/app_dev.php?{R:2}" logRewrittenUrl="true"/>
</rule>  

I tried this and it ain't working:

<rule name="RewriteRequestsToPublic" stopProcessing="true">
   <match url="^(/)(.*)$" />
   <action type="Rewrite" url="web/app_dev.php?{R:2}" logRewrittenUrl="true"/>
</rule>  

1 Answer 1

4

You should point your IIS root directory of website to your web directory (not symfony root directory). This will remove web from your url and (more important) this is adviced because of security reason - only web directory should be accessible

EDIT: If you do not want to change your wwwroot then I would advice to use symbolic link in windows (mklink command) and create a link called symfony under your wwwroot directory pointing to your symfony's web directory (in this scenario it does not matter where your symfony project is).

Then you can access /symfony url and symbolic link will redirect you to your web directory

Sign up to request clarification or add additional context in comments.

3 Comments

Noted. However, it is on a developer machine and security is not a concern. Root directory is pointed up one level form Symfony and I would like to keep it that way so as to have access to multiple sites under root directory in a quick and easy manner.
Unfortunately proposed solution does not work. Created symlink, tested it and it points to the web folder correctly. Trying to navigate in browser gives 404. I think it is because web.config is under symfony folder (one level up) which is now not accessible.
I guess web.config is a equivalent of .htaccess? If so, it should be in your web directory. Try to type /symfony/app_dev.php or /symfony/index.php - if this works it's .htaccess issue

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.