0

i have this script:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?(images|orders)/

RewriteRule ^(.*)$ index.php?til=$1 [L,QSA]

it's working fine in my localhost but when i upload it to my hosting and go to www.domain.com/images/ it's redirecting to index.php?til=403.shtml

Ered
  • 465
  • 1
  • 6
  • 23
  • Live server is causing 403, you need to find out why? – anubhava Jun 09 '14 at 20:34
  • yeah its werid becasue in my localhost shows `Forbidden You don't have permission to access /images/ on this server.` and in my live server i get: `Forbidden You don't have permission to access /images/ on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.` – Ered Jun 09 '14 at 20:38
  • So the question why is `/images/` folder forbidden? – anubhava Jun 09 '14 at 20:42
  • i guess my hosting block by default the indexes `-Indexes` – Ered Jun 09 '14 at 20:46
  • In that case your shouldn't try to open `/images/` to list all the images. – anubhava Jun 09 '14 at 20:57

2 Answers2

1

mod_rewrite repeatedly scans htaccess files until no more substitutions have been made. The [L] flag means "last in this cycle". W.e.f. Apache 2.4 the [End] flag does what you intend. See my Tips for debugging .htaccess rewrite rules for more discussion.

I suspect that the issue is that the dhared host has multiviews enabled and you don't on your dev instance. Always try to align your dev instance as much as possible to the hosting providers. If you don't need it, then always turn multiviews off.

You can always disable this on a per-rule basis by adding the [NS] flag. In this case is you add it to the first rule then you will find that it now works.

Community
  • 1
  • 1
TerryE
  • 10,724
  • 5
  • 26
  • 48
0

ok this seemed to work..

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/orders/.* [NC]
RewriteCond %{REQUEST_URI} !^/401.shtml [NC]
RewriteCond %{REQUEST_URI} !^/403.shtml [NC]

RewriteRule ^(.*)$ index.php?til=$1 [L,QSA]
Ered
  • 465
  • 1
  • 6
  • 23