1
votes

Maybe this has been answered before, I can't seem to get any thing to work. I am new to rewriting.

What I have is this, http://www.domain.com/path1/path2/path3/page

What I want is to remove only path2 from the url, so the result will be http://www.domain.com/path1/path3/page

How can I achieve this without redirecting?

This is currently what I have:

RewriteRule ^/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ $1/$3 [L]

This is located in my vhost file.

Thanks!

1

1 Answers

0
votes

Try changing your regex to account for everything after the second path:

RewriteRule ^/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/(.+)$ /$1/$3 [L]

Also, make sure you turn on the rewrite engine:

RewriteEngine on