Targeting homepage (not sub pages/dirs/)

What should I add to this directive to target also the home page (root
of
the website, e.g. website.com)?
I already have ‘index.php’ in the directive but what if I visit
website.com(without /index.php)?

if ($request_uri ~*
“(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]±sitemap([0-9]+)?.xml)”)

I think I need to add another if, this time not with ~* though but with

Something like

if ($request_uri = “(/)”)

…?

Thanks in advance!

On Fri, Jan 17, 2014 at 06:40:37PM +0100, Lorenzo R. wrote:

Hi there,

What should I add to this directive to target also the home page (root of
the website, e.g. website.com)?

I’d suggest

location = / {}

as being simplest.

But if you want it to be part of the already-present regex, then you
want to match either “exactly /” or “starts with /?”.

“exactly” is “start of string, /, end of string”.

“starts with” is “start of string, /, ?”.

Check your regex manual for which bits need to be escaped and which bits
mean “start” and “end”.

Good luck with it,

f

Francis D. [email protected]