0

I need to remove index.php? from URL.

From: https://example.com/index.php?/discover/

To: https://forum.fibaro.com/discover/

I tried everything, but doesn't work :/

2
  • Whatever you tried put it in question. Commented Mar 14, 2018 at 10:45
  • but it does not work, so why? Commented Mar 14, 2018 at 11:33

1 Answer 1

1

I think you were trying to mach against URI only so, let me explain something here :

https://example.com/index.php?/discover/

This part index.php is URI , then there is ? and after that is /discover/ , the last part is query string so to match against it you could use QUERY_STRING or THE_REQUEST Server-Variables according to what you need but when using REQUEST_URI you match only against URI part.

Try the following:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/index\.php\?\/(.*)\sHTTP.*$
RewriteRule ^index\.php$  /%1? [L,R=301]
RewriteRule !^index\.php$  /index.php?%{REQUEST_URI} [L]

The code above will redirect https://example.com/index.php?/discover/ to https://example.com/discover/ externally and then redirect it again to same path .

Note: clear browser cache then test it .

Sign up to request clarification or add additional context in comments.

Comments

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.