Brave Type
Brave Type

Reputation: 165

redirect issue with htaccess file

I have a problem in my htaccess rules.

Here my htaccess:

Options -MultiViews

RewriteEngine On  
RewriteBase /
RewriteRule ^/(css|js|img)/([a-zA-Z0-9_-]+)?$ /$1/$2 [L,QSA,R=permanent]

RewriteRule ^create$ create.php [L]
RewriteRule ^delete$ delete.php [L]
RewriteRule ^error$ error.php [L]

RewriteRule ^([\$\.A-Za-z0-9_-]+)$ fetch.php?fetch=$1 [QSA,L]
RewriteRule ^([\$\.A-Za-z0-9_-]+)/make$ fetch.php?fetch=$1&make=do [QSA,L]
RewriteRule ^([\$\.A-Za-z0-9_-]+)/made$ fetch.php?fetch=$1&made=done [QSA,L]

DirectoryIndex index.php

Each time i go to my website directory (http://localhost/myscript) i got redirected many time and receive a message: Page not redirect properly.

When i remove this lines:

RewriteRule ^([\$\.A-Za-z0-9_-]+)$ fetch.php?fetch=$1 [QSA,L]
RewriteRule ^([\$\.A-Za-z0-9_-]+)/make$ fetch.php?fetch=$1&make=do [QSA,L]
RewriteRule ^([\$\.A-Za-z0-9_-]+)/made$ fetch.php?fetch=$1&made=done [QSA,L]

I got it work ... but this three lines are importants for my script.

Help to figure it out please.

Upvotes: 1

Views: 33

Answers (1)

Brave Type
Brave Type

Reputation: 165

Anyone interested on this. I added this conditions to my code and resolved the problem.

# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

Got response from here: htaccess Rewrite Rule

Upvotes: 1

Related Questions