Reputation: 6100
I have a project directory structure as below
| project
--| controllers
--| views
--| index.php
--| .htaccess
--| config
--| .htaccess
Here's my main .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)?$ views [L]
</IfModule>
and my view .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.+$ index.php [L]
</IfModule>
I am able to redirect all my requests to views/index.php. When i go to www.example.com/project it will be redirected to www.example.com/project/views.
My main problem is i don't want to have views in my URL. If i go to www.example.com/project it should execute views/index.php but URL does not change. Can anyone help me to figure out this problem?
Upvotes: 1
Views: 487
Reputation: 784898
Keep this in main .htaccess:
RewriteEngine On
RewriteRule .* views/$0 [L]
Then have it like this in .views/.htaccess
:
RewriteEngine on
RewriteRule ^index\.php$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Upvotes: 1