?
Solved

htaccess: redirect URL with folders to URL without folders

Posted on 2009-12-21
6
Medium Priority
?
423 Views
Last Modified: 2013-11-30
I am trying to add a rule to .htaccess that will redirect URLs containing specific folders.

I wan to redirect any URL containing "/download/zips/" to a URL without "/download/zips/". The folder "/download/zips" no longer exists so I need a redirect and not a rewrite.

For example, if a user entered this URL:

www.mysite.com/download/zips/somepage.php

...I want to send them to this URL:

www.mysite.com/somepage.php

I can't get the regex syntax right. Can anybody help?
0
Comment
Question by:bearclaws75
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:amrens
ID: 26099277
This should do it for you and also will help for future redirects : happy redirecting

http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
0
 
LVL 3

Expert Comment

by:amrens
ID: 26099293
301 redirect is the solution for you.
0
 
LVL 3

Expert Comment

by:amrens
ID: 26099304
Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:bearclaws75
ID: 26099328
Sorry - neither solution is sufficient.

The link provided does not explain how to handle this condition.

A Redirect only works if the URL is known. In my case, I know the middle part of the URL but not the file being accessed, so I need a dynamic solution that will look for "/download/zips/" in the URL string, remove it and redirect the user to the new URL.
0
 
LVL 14

Accepted Solution

by:
jb1dev earned 1000 total points
ID: 26099371
Try this.

RewriteEngine On
RewriteRule (.*)download/zips(.*) /$1$2 [R]

Open in new window

0
 

Author Closing Comment

by:bearclaws75
ID: 31668682
This worked perfectly. Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
In this article, the configuration steps in Zabbix to monitor devices via SNMP will be discussed with some real examples on Cisco Router/Switch, Catalyst Switch, NAS Synology device.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

839 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