.htaccess Redirect a subdirectory to its index.php file
Get the solution ↓↓↓I've been stuck on this one for a long long time. I will try to explain the problem but feel free to ask for more details if it is not clearly explained.
I have two directories, the document root directory and the cms subdirectory. What I am trying to do is to redirect every URL without a subdirectory in it (for example domain.com, domain.com/help) to the index.php of the root directory and in the same time to redirect every URL containing the cms subdirectory (example - domain.com/cms/item) to the index.php of the cms directory. This is my .htaccess file but sadly it is not working:
Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!cms/)(.+)$ /index.php?u=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cms/(.+)$ /cms/index.php?u=$1 [NC,QSA,L]
Any help will be greatly appreciated as this is a crucial part of the project and it is required as index.php files handle the SEO and include the required files.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function format() on string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.