301 redirects - redirect rule - rule is adding on last bit of url


The intended URL for this rewrite rule is: http://mysite.com/products/bla/

rewriterule ^pipeline/ATX-101-mechanism-of-action(.*)$ http://mysite.com/products/bla/$1 [r=301,nc]

but instead the above rule is redirecting me to:


any ideas what I'm doing wrong?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark BullockQA EngineerCommented:
What is the input URL?

Without knowing that I would suggest removing /$1 from the substitution
Mark BullockQA EngineerCommented:
Also change rewriterule  to RewriteRule
phillystyle123Author Commented:
removing /$1 doesn't change anything. This is the input URL:

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Mark BullockQA EngineerCommented:
I tested using this tool http://martinmelin.se/rewrite-rule-tester/

With the URL you gave and this RewriteRule:
RewriteRule ^pipeline/ATX-101-mechanism-of-action(.*)$ http://mysite.com/products/bla [r=301,nc]

Open in new window

And the resulting URL was http://mysite.com/products/bla

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
phillystyle123Author Commented:
applying your changes to my rule -still not redirecting correctly.

RewriteRule ^pipeline/ATX-101-mechanism-of-action(.*)$ http://mysite.com/products/atx-101 [r=301,nc]

maybe its the atx-101 part
Mark BullockQA EngineerCommented:
I tested this in apache 2.2.26 on my mac and the redirect worked.
Are you sure you restarted Apache after changing your .htaccess file?
phillystyle123Author Commented:
why do i need to restart apache? seems like all of the other redirects on my .htaccess file take effect w/o restarting apache.
Mark BullockQA EngineerCommented:
I was trying to think why you can't get the same result.
You can enable logging for rewrites and see which rule is used.

From my httpd.conf:
<IfModule mod_rewrite.c>
        RewriteLock /var/log/apache2/rewrite.lock
        RewriteLogLevel 3
        RewriteLog /var/log/apache2/rewrite.log

Open in new window

From rewrite.log after I requested http://www.oldsite.com/pipeline/ATX-101-mechanism-of-action - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (3) [perdir /usr/docs/host.example.com/] add path info postfix: /usr/docs/host.example.com/pipeline -> /usr/docs/host.example.com/pipeline/ATX-101-mechanism-of-action - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (3) [perdir /usr/docs/host.example.com/] strip per-dir prefix: /usr/docs/host.example.com/pipeline/ATX-101-mechanism-of-action -> pipeline/ATX-101-mechanism-of-action - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (3) [perdir /usr/docs/host.example.com/] applying pattern '^pipeline/ATX-101-mechanism-of-action(.*)$' to uri 'pipeline/ATX-101-mechanism-of-action' - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (2) [perdir /usr/docs/host.example.com/] rewrite 'pipeline/ATX-101-mechanism-of-action' -> '/products/bla' - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (2) [perdir /usr/docs/host.example.com/] explicitly forcing redirect with http://host.example.com/products/bla - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (1) [perdir /usr/docs/host.example.com/] escaping http://host.example.com/products/bla for redirect - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1e72a0/initial] (1) [perdir /usr/docs/host.example.com/] redirect to http://host.example.com/products/bla [REDIRECT/301] - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1eb2a0/initial] (3) [perdir /usr/docs/host.example.com/] add path info postfix: /usr/docs/host.example.com/products -> /usr/docs/host.example.com/products/bla - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1eb2a0/initial] (3) [perdir /usr/docs/host.example.com/] strip per-dir prefix: /usr/docs/host.example.com/products/bla -> products/bla - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1eb2a0/initial] (3) [perdir /usr/docs/host.example.com/] applying pattern '^pipeline/ATX-101-mechanism-of-action(.*)$' to uri 'products/bla' - - [28/Feb/2015:20:46:00 --0800] [host.example.com/sid#7f88ba0fea88][rid#7f88ba1eb2a0/initial] (1) [perdir /usr/docs/host.example.com/] pass through /usr/docs/host.example.com/products

Open in new window

phillystyle123Author Commented:
Strangest thing -the rewrite actually worked - my original rewrite rule -for some reason didn't take right away. Maybe a cache issue.

Thanks for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.