Stephen Walsh
Stephen Walsh

Reputation: 835

.htaccess RewriteCond regex not matching

Can somebody please explain to me why https://www.example.com/meetings-and-events/soho doesn't match:

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com\/meetings-and-events\/soho$ [NC]

Thanks!

Upvotes: 1

Views: 41

Answers (1)

anubhava
anubhava

Reputation: 786289

%{HTTP_HOST} only matches domain name in the request. To match URI, use %{REQUEST_URI} as this:

RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/meetings-and-events/soho/?$ [NC]

Upvotes: 1

Related Questions