T
T
TrueDrago2013-01-28 21:15:18
Apache HTTP Server
TrueDrago, 2013-01-28 21:15:18

Regular expression for 301 redirect

In my favorite project, there was a small jamb - URLs like /abc-abc/ and /abc-abc/abc-abc-xyz/ appeared when they should be /abc/ and /abc/abc-xyz/ respectively.

Please help me to correctly compose a rewrite rule for redirecting from incorrect urls to correct ones!
My version normally works out the 1st url, but on the second one it messes up, making it out of
it
. , or like this: /{%webroot path%}/{%webroot path%}/abc/abc-xyz/ for the second

  RewriteCond %{REQUEST_URI} ^(.*)abc-abc(.*)$
  RewriteRule  ^(.*)abc-abc(.*)$ $1abc$2 [R=301,L]

Where should I dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TrueDrago, 2013-01-28
@TrueDrago

A couple of minutes after the post, I realized that I forgot about

RewriteBase /

With him everything works as it should.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question