我擁有與另一個項目共享的資源。我將展示的產品圖片存儲在我使用symfony的新項目中的一個文件夾中...無法讓symfony遵循我的資源的符號鏈接
在我的symfony項目中,在/web/images
文件夾中,我創建了一個符號鏈接到文件夾我的照片被存儲。確保符號鏈接指向的圖片文件夾下的每個文件和文件夾的權限都設置爲777,任何人都可以訪問它們。
一切工作正常,直到我啓用mod的Apache重寫。 /web/images
文件夾中的圖片完美顯示,購買任何通過符號鏈接訪問的內容都未顯示。我立刻認爲符號鏈接是這種行爲的原因,我檢查了我的網站的Apache配置。此外,閱讀symfony的,我檢查了/web
文件夾下的文件.htaccess
並添加一行:
Options FollowSymLinks
這也不能工作。
這裏是我的網站配置:
#<VirtualHost mydomain.com>
<VirtualHost *:80>
#ServerAdmin [email protected]
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>
這是我的.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>
任何建議?感謝您花時間閱讀和回答!
編輯:
我試過Znarkus'解決方案,並沒有工作!我認爲這可能意味着符號鏈接不是問題。
圖片文件夾中的文件沒有擴展存儲。由於比,我不能用image_tag()
幫手symfony的,它在默認情況下,如果沒有extention給出的文件名追加.png
的...這是即時顯示在我的模板圖像的方式:
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"/>';
}
奇怪事情是/images/no_picture.jpg
顯示完美。再次感謝您給我的任何幫助!
或硬鏈接到文件...可能不是最好的主意,但它肯定會工作 – DaveRandom
@Dave:但是這需要他們在同一個捲上,對不對? – Znarkus
是的......它在Q的任何地方都說它們不在同一個體積中?真正的問題 - 即使在重新閱讀之後,我非常疲倦,可能已經錯過了...是的,我現在要停止了,疲倦的答案對任何人都沒用。 – DaveRandom