Question

Good evening everybody,

I'm writing here because I think I have a basic problem. As I said, I think.

I'm actually working on a symfony2 project (my portfolio) and I have an issue since I pushed everything online.

The fact is that, as being a student, I would like to keep some files accessible through some urls targeting a specific folder on my server (to use it as a demo).

Let me give you more details. I have a page project. I'm setting an absolute url from the backend (i.e: www.example.com/project). The project folder itself is uploaded but when I try to access the url by clicking the link I've set I get this error:

"Unable to generate a URL for the named route "http://www.example.com/project" as such route does not exist".

Also in my twig I'm using

{{ path(project.link) }}

EDIT: project.link is the value entered in my backend (the url www.example.com/project) that I'm setting in my controller.

At this point I'm not really sure if it's about .htaccess file or the routing.php. Any idea?

EDIT:

here is the .htaccess I have in my web directory:

<IfModule mod_rewrite.c>
    RewriteEngine On

    #<IfModule mod_vhost_alias.c>
    #    RewriteBase /
    #</IfModule>

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

<files php.ini>
  order deny,allow
  deny from all
</files>

Thanks in advance,

D

Was it helpful?

Solution

If project.link is an already generated URL, then just do {{ project.link }}.

{{ path() }} is for generating a named route, for example in your routing.yml file.

As for the .htaccess file. Try changing it to:

<IfModule mod_rewrite.c>
    RewriteEngine On

    #<IfModule mod_vhost_alias.c>
    #    RewriteBase /
    #</IfModule>

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

<files php.ini>
  order deny,allow
  deny from all
</files>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top