0

I have a simple CMS file structure:

application/
data/
src/
web/
.htaccess
index.php

I want to redirect all request to /index.php execept if file or directory exists, then I want to redirect all to /web. Example: http://localhost.com/news/example-news to index.php/ http://localhost.com/images/logo.png to web/images/logo.png

Now my .htaccess looks: .htaccess

Grzegorz
  • 49
  • 2
  • 10

2 Answers2

3

Try this...

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ /web [L]

RewriteRule ^.*$ index.php [L]

The first rule will catch any request that can be mapped to an existing file or directory and rewrite to web folder. The second rule (without rewritecond) will catch the remaining and rewrite th index.php

Quickpick
  • 163
  • 6
1

You just need to change your code to look like this.

change this

RewriteCond %{REQUEST_URI} !^/index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php [NC,L]
RewriteRule ^(/)?$ index.php [L]

to this

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /web/index.php [L]

RewriteRule ^(.*)$ index.php [NC,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95