Reputation: 198
I have following project structure:
Project(root)
page1\index.php
page2\index.php
Project\index.php
I need to redirect all request to page1\index.php and page2\index.php to base index.php which i am not being able to.
If i go to route page1\index.php or page1\ it goes to page1\index.php but i want it to redirect to base index.php.
My current .htaccess code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
Upvotes: 1
Views: 206
Reputation: 785098
You may use this rule in site root .htaccess:
DirectoryIndex index.php
RewriteEngine On
# skip rule below if URI is already /index.php
RewriteRule ^index\.php$ - [L,NC]
# rewrite to /index.php if URI has /index.php or request
# is for a non-file
RewriteRule /index\.php [OR,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php [L]
Upvotes: 1