Friendly URL, images do not appear even putting absolute path

Asked

Viewed 962 times

3

I am facing this problem with my friendly URL, even putting the absolute path it does not show the images.
But the images that are in a folder in the same location of .htacess appear normally, the ones that do not appear are the ones that are in the following directory admin/imgsupload.

I have also tried to use another configuration in htacess and the base tag, but without success, remembering that you are only giving this problem in the images in the directory admin/imgsupload, which is in the same folder as the .htacess works normally.

Follow the codes of my htacess and how I’m putting the images:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projetolcj/
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|jpeg|png|js|css|swf|ico|txt|pdf|xml|woff)$
RewriteRule ^ - [L]
RewriteRule ^(.*) url.php
</IfModule>

Img:

<img src="/projetolcj/admin/<?php echo $linha["imagem"]; ?>" alt="parceiro" class=" thumbnail img-responsive">
  • 2

    possible duplicate of User-friendly URL using HTACCESS

  • Vintages, do pages work normally? Try using the parameters RewriteCond %{REQUEST_FILENAME} !-d and RewriteCond %{REQUEST_FILENAME} !-f instead of that regular expression.

  • I tried that way and it didn’t work, yes all pages work normally...

  • Take a look here: http://answall.com/questions/53973/url-amig%C3%A1vel-como-fazer-funcionar-com-htaccess/86900#86900

  • 1

    Only what you are doing is quite the opposite: created a conditional to deny any "file" containing the extensions (jpg|gif|jpeg|png|js|css|swf|ico|txt|pdf|xml|woff).

  • I tried to change that, and it didn’t work either...

Show 1 more comment

2 answers

2

Put that on the head of the site: <base href="http://localhost/Sua_Pasta/"> if you are working locally or <base href="http://seusite.com/"> if you already have them in the accommodation

1

I believe this way you will release the files you need:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /projetolcj/
 #acessa as requisições abaixo
 #se for um arquivos vazio
 RewriteCond %{REQUEST_FILENAME} -s [OR]
 #ou se for um link de referência (simbólico)
 RewriteCond %{REQUEST_FILENAME} -l [OR]
 #ou se for um diretório
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 RewriteRule ^(.*) url.php
</IfModule>

But if you want to release only these files from the list, then do so:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /projetolcj/
  #ignora todas as regras abaixo quando for arquivo 
  RewriteCond %{REQUEST_FILENAME} !-f
  #ignora todas as regras abaixo quando for diretório 
  RewriteCond %{REQUEST_FILENAME} !-d
  #qualquer coisa que contenha as extensões abaixo não serão tratadas pelas regras a seguir, somente nesta condição
  RewriteCond $1 !^(\.jpg|\.gif|\.jpeg|\.png|\.js|\.css|\.swf|\.ico|\.txt|\.pdf|\.xml|\.woff)
  RewriteRule ^ - [L]
  RewriteRule ^(.*) url.php
</IfModule>

To edit permissions on Linux:

Directory:

user@host:/projeto/imagens$ sudo chmod 775 -R ./

Archives:

user@host:/projeto/imagens$ sudo chmod 664 ./

To edit the permission in Windows watch this video.

  • I tried that way,.

  • Take a look here: http://gustavodutra.com/geek/como-usar-mod_rewrite-de-verdade

  • 404 error is page not found. It means that the file you are trying to access is not in the folder, not that it was denied.

  • See if your folder is 775 allowed and if the file is 664 allowed

  • Excuse me for ignoring Van,?

  • It’s linux or windows?

  • Windows, I don’t know if it comes to the case but I’m using wamp...

  • I work with Linux, and if your question is how to give write and read permission in windows folders, I think you better open another question for this.

  • my tip is to do tests: first try to access the file without using rewrite mode first. takes your file .htaccess rename to _.htaccess and try to open the file directly in the url.

  • Okay, thanks anyway, you helped me a lot.

  • If you don’t open up the problem isn’t in the .htaccess.

  • Most of the rewriting problems are precisely when the whole system is pointed to an index.php file and it can’t find the images, js, css, etc... the ideal is for you to put it in a public folder (public). Outside the execution of your system.

  • And in this public folder, you have to grant full write access.

  • If you are using some framework in your project, it usually comes with an original configuration that gives permission for the files in the .htaccess, but fortunately, if you are editing this manually, it is recommended to have a functional setting as a basis, if it is your case, I can pass you a .htaccess that has several rules for it.

  • I am editing manually,if you can help me with that I would appreciate,I also realized that my image upload is not being able to send the image to the folder that should send...

Show 10 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.