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 admin#mydomain.com
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!!!
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.
Related
I have a website made with Symfony 2.8.22 running with Apache 2.4.18. I have RewriteEngine activated in the virtualhost to not show the .php extension in the url. However I have 2 problems. The first one is I do get the .php extension via url. The second problem is I have a loop in the login page; once I input the credentials it reloads the same login page again, and again. That happens in Chrome and Firefox, however in Microsoft Edge that loop wont happen, it just follow to the next page.
Why is that?
Where's my virtualhost file:
<VirtualHost *:80>
ServerName ip.ip.ip.ip
DocumentRoot /var/www/html/website/web
<Directory /var/www/html/website/web>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule (.*)\.php $1 [R=301,L]
</IfModule>
</Directory>
<Directory /var/www/project>
Options FollowSymlinks
</Directory>
ErrorLog /var/log/apache2/error_website.log
CustomLog /var/log/apache2/access_website.log combined
</VirtualHost>
Thanks in advance.
Best regards.
I am not certain why you are trying to forcably remove .php from the web address bar. If you follow the Symfony Configuration guide it will give you an .htaccess file that works and will not display .php extensions:
<VirtualHost *:80>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /var/www/project/web
<Directory /var/www/project/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/project/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
Possible Duplicate
I did the same. But instead of using .htaccess I put these lines
RewriteEngine On
RewriteCond %{HTTP_HOST} ^one\.domain\.com
RewriteRule ^(.*)$ /folder/$1 [R=301]
to /etc/apache2/sites-available/default.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All // I even changed None to All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All // I even changed None to All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTP_HOST} ^one\.domain\.com
RewriteRule ^(.*)$ /folder/$1 [R=301]
</VirtualHost>
After restarting apache2, When I browse one.domain.com , Mozzila, IE Chrome not responding, But safari gives error
Since it's a 301 you're telling the browser to redirect to one.domain.com/folder which still passes your host condition. Meaning on redirect 2 you're on page one.domain.com/folder/folder
Hello I am currently trying to set up dynamic subdomains picked up from my database on my codeigniter installation whenever i try to access a subdomain i get a 403 error I realize a couple of issues might be causing this I however cannot determin which one it is I am sorry if I am asking an obvious question but i a quite new to this
here is my virtual host set up
<VirtualHost *:80>
DocumentRoot /var/www
ServerName www.example.mobi
ServerAlias example.mobi
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/subs
ServerName example.mobi
ServerAlias *.example.mobi
<Directory /var/www/subs/>
# Options +Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Here is my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#this is to allow no indexes
Options All +Indexes
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
AddType image/x-windows-bmp bmp
This is the error i see when i try and access a subdomain
[error] [client x.x.s.x] Directory index forbidden by Options directive: /var/www/subs/
Additional information would be that i am using this guide
http://code.tutsplus.com/tutorials/basecamp-style-subdomains-with-codeigniter--net-16330
to set up my codeigniter for the subdomains
*also when i access the domain
"domain.mobi"
'domain' is echoed as i have set it to echo the subdomain
I since found a solution the subdomain virtual host just needs to be pointed to the same directory as the main domain and then I can use the subdomain as a parameter
<VirtualHost *:80>
**DocumentRoot /var/www**
ServerName example.mobi
ServerAlias *.example.mobi
<Directory /var/www/subs/>
# Options +Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
I've created a simple Zend Framework 1.12 test app via the zf.bat on my windows machine (xampp, php5.3): "zf create project testapp"
After that i've created an new controller called 'FoobarController' next to the 'IndexController'.
Now I can switch between these urls:
localhost/projects/testapp/public/
localhost/projects/testapp/public/index
localhost/projects/testapp/public/foobar
Now I have uploaded the whole testapp into the web server directory of my raspberry pi (192.168.1.100, Apache2, PHP5.3, ModRewite On, AllowOverride All).
This urls are working fine when I call the raspberry from the windows machine:
192.168.1.100/sites/testapp/public
192.168.1.100/sites/testapp/public/foobar
This one will display: "The requested URL /sites/testapp/public/index was not found on this server"
192.168.1.100/sites/testapp/public/index
Has someone an idea why the url to the "index" controller wont work properly on my raspberry? (I did nothing more than the explained steps)
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess:
RewriteEngine On
RewriteBase /sites/testapp/public
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
I was making a .htaccess file to run a framework that I was testing, but when I tried to access to my localhost, the folder where is located the framework's files didn't show up.
If I try to access, requesting the localhost/my_hidden_folder/ this fires a 500 error, internal server error.
This behaviour is result of some wrong configuration with my apache|.htaccess, I'm pretty sure because the same .htaccess in another server works fine.
Here is my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
And here is my default file from /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/entrega2>
AllowOverride All
</Directory>
<Directory /var/www/unlp>
AllowOverride All
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Both folders, /var/www/unlp and /var/www/entrega2 have the same .htaccess file, and both are hidden.
The most basic redirect in the .htacces file doesn't work, in my localhost, but in the server works. Maybe I have a module disabled?
Is there a +FollowSymlinks in .htaccess? This usually does the 500 error on Linux systems that have already activated the option or on Windows.
Try to run phpinfo() to make sure the mod-rewrite is activated.
Create simple php file in your web root folder, which contains:
<?php
phpinfo();
?>