Dionis L Dionis L - 2 months ago 17
Apache Configuration Question

Links sometimes do not work cause of htacess

When I try to open :

http://custom.dev/pages/tpl/front/img/main.jpg
works

but when I try to open same file from another directory :

http://custom.dev/uploads/home-banners/main.jpg


It do not works , it redirect me to home page and in apache logs I see :

"GET /uploads/home-banners/main.jpg HTTP/1.1" 302 454 "http://custom.dev/"


If I delete .htacess both links open , but site needs htacess to work well

I use the next .htaccess , what could be the problem?

RewriteEngine On

#gzip
#AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
#gzip


#FileETag none

##########################################################################
#### ADMIN
##########################################################################

# 8 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7&var7=$8&var8=$9 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7&var7=$8&var8=$9 [L]
# 7 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7&var7=$8 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7&var7=$8 [L]
# 6 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7 [L]
# 5 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6 [L]
# 4 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5 [L]
# 3 vars
RewriteRule wf-admin/(.*)/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4 [L]
RewriteRule wf-admin/(.*)/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3&var3=$4 [L]
# 2 var
RewriteRule wf-admin/(.*)/(.*)/ pages/wfagate.php?file=$1&var1=$2&var2=$3 [L]
RewriteRule wf-admin/(.*)/(.*) pages/wfagate.php?file=$1&var1=$2&var2=$3 [L]
# 1 var
RewriteRule wf-admin/(.*)/ pages/wfagate.php?file=$1&var1=$2 [L]
RewriteRule wf-admin/(.*) pages/wfagate.php?file=$1&var1=$2 [L]
# 0 var
RewriteRule wf-admin/ pages/wfagate.php?file=$1 [L]


##########################################################################
#### FORONT END
##########################################################################

# 6 vars
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7 [L]
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6&var6=$7 [L]
# 5 vars
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6 [L]
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/(.*) /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5&var5=$6 [L]
# 4 vars
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/ /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5 [L]
RewriteRule (.*)/(.*)/(.*)/(.*)/(.*) /index.php?file=$1&var1=$2&var2=$3&var3=$4&var4=$5 [L]
# 3 vars
RewriteRule (.*)/(.*)/(.*)/(.*)/ /index.php?file=$1&var1=$2&var2=$3&var3=$4 [L]
RewriteRule (.*)/(.*)/(.*)/(.*) /index.php?file=$1&var1=$2&var2=$3&var3=$4 [L]
# 2 var
RewriteRule (.*)/(.*)/(.*)/ /index.php?file=$1&var1=$2&var2=$3 [L]
RewriteRule (.*)/(.*)/(.*) /index.php?file=$1&var1=$2&var2=$3 [L]
# 1 var
RewriteRule (.*)/(.*)/ /index.php?file=$1&var1=$2 [L]
RewriteRule (.*)/(.*) /index.php?file=$1&var1=$2 [L]
# 0 var
RewriteRule (.*)/ /index.php?file=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?file=$1 [L]

RewriteRule scripts.js /engine/include/functions/loadFiles.php
RewriteRule styles.css /engine/include/functions/loadFiles.php?what=css

Answer

You have multiple rules that might be affecting existing files or directories.

Insert this rule just below RewriteEngine On line to skip all files and directories:

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]