Reputation: 4038
i have the resources shared with another project. The pictures of the products i will show, are stored in a folder out of my new project for which im using symfony...
In my symfony project, in the /web/images
folder, i created a symbolic link to the folder where my pictures are stored. im sure the permissions of every file and folder under the pictures folder pointed by the symlink are setted 777, anyone can access to them.
Everything worked fine until i enabled the mod rewrite of apache. Pictures on the /web/images
folder were shown perfectly, buy anything accessible through the symlink wasn't shown. I immediately thought the symlink was the reason of this behavior, and i checked my apache configuration for the site. Also, reading on symfony, i examined the .htaccess
file under the /web
folder and added the line:
Options FollowSymLinks
This didn't work either.
Here's my site configuration:
#<VirtualHost mydomain.com>
<VirtualHost *:80>
#ServerAdmin webmaster@localhost
ServerAdmin [email protected]
ServerName mydomain.com
ServerAlias www.mydomain.com
#DocumentRoot /var/www
DocumentRoot /srv/www/mydomain.com/public_html/
<Directory />
Options FollowSymLinks
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
#<Directory /var/www/>
<Directory /srv/www/mydomain.com/public_html/>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
#AllowOverride None
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#Options +ExecCGI -MultiViews +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
#ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog /srv/www/mydomain.com/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
#CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog /srv/www/mydomain.com/logs/access.log combined
Alias /sf /home/victor/projects/vitoquen/tienda/lib/vendor/symfony/data/web/sf
<Directory "/home/victor/projects/vitoquen/tienda/lib/vendor/symfony/data/web/sf">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from All
</Directory>
#Alias /doc/ "/usr/share/doc/"
#<Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# #AllowOverride None
# AllowOverride All
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#</Directory>
</VirtualHost>
And here's my .htaccess
:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Any suggestions?? thanks for taking the time of reading and answering!!!
EDIT:
I tried the Znarkus' solution, and didnt work! this, i think, can mean that the symlink was not the problem.
Files in the pictures folder are stored without extention. Because of than, i cant use the image_tag()
helper of symfony, which appends .png
by default to the file name if no extention is given... this is the way im displaying images in my template:
if (strcmp($producto->foto, "SI") == 0) {
echo '<img src="/images/productos/'.$producto->id.'_muestra" width="102" height="84" alt="Imagen de muestra"/>';
} else {
echo '<img src="/images/no_picture.jpg" width="102" height="84" alt="Imagen de muestra"/>';
}
The strange thing is that /images/no_picture.jpg
is shown perfectly. Thanks again for any help you can give me!!!
Upvotes: 1
Views: 3472
Reputation: 24254
Symfony problably doesn't support symlinks. Try doing mount --bind
instead, which should be transparent to the application.
Your updated question: You must have an extension for the <img />
tag to work.
Upvotes: 1