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 I'm using symfony...
In my symfony project, in the /web/images
folder, I created a symbolic link to the folder where my pictures are stored. I'm sure the permissions of every file and folder under the pictures folder pointed by the symlink are set to 777, anyone can access them.
Everything worked fine until I enabled the mod rewrite of apache. Pictures on the /web/images
folder were shown perfectly, but anything accessible through the symlink wasn't shown. I immediately thought the symlink was the reason for 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??
I tried mounting the folder with the --bind option, and it didn't work! This, I think, can mean that the symlink was not the only problem.
Files in the pictures folder are stored without extension. Because of that, I can't use the image_tag()
helper of symfony, which appends .png
by default to the file name if no extension is given... this is the way I'm 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!!!
BTW! I have the same configuration on two test servers; one using Debian 6 and the other one with Ubuntu 11.04. I have the same behavior on both servers.
PS: Sorry for my english! thanks to nikai who corrected my spelling...
.htaccess
file under the/web/images
folder, and wrote this:Options +FollowSymLinks +ExecCGI <IfModule mod_rewrite.c> RewriteEngine Off </IfModule>
. It just disables apache'smod_rewrite
only for the/web/images
folder. Any better solution is welcome!!!