Reputation: 1081
I need to rewrite a url.
Source: domain/event-detail/sport/event/?event=171990
Target: domain/event-detail/?event=171990
but the Source URL should be displayed in the address bar.
I thought of something like:
if url contains "event-details" and /*/*/?event=XX (/event-details/*/*) -> /event-detail/?event=XX
And then a rewrite rule to display the source url. How to do it?
Upvotes: 0
Views: 62
Reputation: 18950
This should do the trick:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/event-detail/.+/.+/$
RewriteCond %{QUERY_STRING} ^event=\d+$
RewriteRule (.*) http://www.example.com/event-detail/? [R=301,L]
Following your logic, capture URIs containing event-detail/.+/.+/
and having a query parameter like event=\d+
Upvotes: 1