Amuk Saxena
Amuk Saxena

Reputation: 1571

Rewrite URL: remove second part of url

I am new to htaccess, I am facing issue. I have following url:

example.com/booking/tickets

I want the following output

example.com/tickets

This is my .htacess file

RewriteEngine on
RewriteRule booking/tickets http://example.com/tickets/$1 [L,QSA]

Problem is page is redirecting to the booking page, I want to call the booking/tickets page and url should rewrite "booking/tickets" to "tickets". So how to achieve this. I need help Thanks in advance

Upvotes: 1

Views: 33

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

If you want to rewrite the url, remove the hostname from rewrite target

RewriteEngine on
RewriteRule ^booking/tickets/?$ /tickets/$1 [L,QSA]

Upvotes: 1

Related Questions