Skip to content

Instantly share code, notes, and snippets.

@semihkeskindev
Created December 14, 2020 14:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semihkeskindev/d1a86db5f54f75f74c42f5daeb80bb04 to your computer and use it in GitHub Desktop.
Save semihkeskindev/d1a86db5f54f75f74c42f5daeb80bb04 to your computer and use it in GitHub Desktop.
Nginx remove index.php
if ($request_uri ~ "^(\/)index\.php$") {
return 302 $1;
}
if ($request_uri ~ "^(\/)index\.php\?(.*)") {
return 302 $1?$2;
}
if ($request_uri ~ "^(\/)index\.php\/(.*)") {
return 302 $1$2;
}
@semihkeskindev
Copy link
Author

A few url examples that showing where will be redirected:

http://example.com/index.php => http://example.com/
http://example.com/index.php/demo => http://example.com/demo
http://example.com/index.php?staging=1 => http://example.com/?staging=1
http://example.com/index.php/demo/index.php/semihkeskin => http://example.com/demo/index.php/semihkeskin
http://example.com/index.php?/demo/index.php/semihkeskin => http://example.com/?/demo/index.php/semihkeskin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment