htaccess redirect for wrong link

Posted on 2011-09-13
Last Modified: 2012-05-12
Hi experts,

I need some help with a redirection in my htaccess. Due to a error in my system I have lots of broken links which I would like to catch for now and redirect to the correct place until the actual problem is solved.

I would like to have in my .htaccess a simples redirect which does the following thing:

The wrong link:

should redirect to:

with other words I need to cut the away from the link if the part is double like in the example above.

Except the sid=0000000000 the url is always the same.

Thank you for your help,
Question by:Oliver2000
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3

Expert Comment

ID: 36530881
RewriteRule ^phpbb/.*(phpbb/.*)$ $1

Author Comment

ID: 36530931
Hi parparov,

Dosent this redirect all kind of other stuff as well like this?
I am not sure if you understand me correct or if I wrote it a little bit missunderstanding.

if you take a look at the wrong url: you see that the system somehow writes the part before the second httpd:// wrong. And in this case I need to cut everything before the second httpd:// away.

out of


but I do not want in ANY OTHER case forward except if there is something in the url before the http://

Author Comment

ID: 36531224
I am not sure but your help ^phpbb/.*(phpbb/.*)$ $1 would end up forwarding also to /phpbb/ or am I wrong?
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Expert Comment

ID: 36531330
No, this line should have two phpbb to redirect. It actually weeds
from any URL

Author Comment

ID: 36531493
hmmm okay let me try....

Author Comment

ID: 36531549
Does not work at all. I placed RewriteRule ^phpbb/.*(phpbb/.*)$ $1  in my .htaccess (root) but when I post the wrong url in my browser continue the file not found like before.

(My .htaccess contains already several other redirects so I know the .htaccess redir is acctually working fine)

any idea?

Expert Comment

ID: 36540203
Hmm... works for me.
What version of Apache are you using?

Maybe put the rule on top of your .htaccess file and add some more definitions before and at the end of it?
RewriteBase /
RewriteRule ^phpbb/.*(phpbb/.*)$ $1 [R,L]

Open in new window


Accepted Solution

Oliver2000 earned 0 total points
ID: 36545433
Hi again,

I did find a better solution and was be able to fix the wrong link from before. Like this I don't need this redirect anymore. thank you for your help.

Author Closing Comment

ID: 36565500
Fixed it myself!

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The viewer will learn how to dynamically set the form action using jQuery.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question