0

Need an htaccess/ mod_rewrite assistance to:

  1. Remove index.php from the display URL
  2. Redirect the non index.php urls to their respective index.php urls without showing index.php
  3. Sometimes there will be url without index.php
  4. The url structure has subfolders after domain and folders after index.php with query string. Tried all the answers but not working.

Example URL:
domain.com/index.php/moduleA/modeuleB?var=1&bvar=2
domain.com/folder/index.php/moduleC/moduleD?var=1&bvar=2
domain.com/folder/index.php/m1/m2/m3/m4/m5

3
  • Tried all the answers but not working. what did you try? which answers? Please show your efforts. What are your example URLS expected to write to? Commented Jul 29, 2017 at 14:31
  • Possible duplicate of Redirect all to index.php htaccess Commented Jul 29, 2017 at 14:40
  • "Remove index.php from the display URL" - Have you already done this in your application? Commented Jul 29, 2017 at 18:19

1 Answer 1

1

Put this in .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

3 Comments

Doesnt replace the index.php? The url remains the same.
Check mod_rewrite enable if not install it will work
Can I also ask what is the point of having the extra two conditions? Can we simply rewrite all index.php?/$1 to $1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.