Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9100407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:51:22+00:00 2026-06-17T00:51:22+00:00

I need help writing an htaccess redirect or rewrite rule (mod_rewrite.c) to handle the

  • 0

I need help writing an htaccess redirect or rewrite rule (mod_rewrite.c) to handle the following situation:


http://www.mysite.com/archive/[YEAR]/archive/[YEAR]/[CORRECT-PATH]

should redirect to:


http://www.mysite.com/archive/[YEAR]/[PATH]

Basically, there are some externals links that have incorrectly doubled-up on the /archive/[YEAR]/ part of the path, where there should only be one instance. I have a sub-directory for each year (/archive/2011, /archive/2012, etc.) – those year directories are the roots of separate Drupal installations – each with their own .htaccess file (which is tripping me up).

The [CORRECT-PATH] bit is usually an alias to a Drupal page, for example:

http://www.mysite.com/archive/2012/winners/all

I’m not so good with wildcard and matching syntaxes – any help would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:51:26+00:00Added an answer on June 17, 2026 at 12:51 am

    Try adding these rules to your document root:

    RewriteEngine On
    RewriteRule ^/?archive/([0-9]{4})/archive/\1/(.*)$ /archive/$1/$2 [L,R=301]
    

    This checks that the year is duplicated, for any 4 digit year. so:

    1. http://www.mysite.com/archive/1234/archive/2345/blah/blah does nothing
    2. http://www.mysite.com/archive/2345/archive/2345/blah/blah gets redirected to
      http://www.mysite.com/archive/2345/blah/blah
    3. http://www.mysite.com/archive/1234/blah/blah does nothing.

    After looking at your problem again, you’re going to need to add rules to each of your /archive/[YEAR] directories:

    RewriteEngine On
    RewriteBase /archive/2011/
    RewriteRule ^archive/[0-9]{4}/(.*)$ $1 [L,R=301]
    

    And change the RewriteBase for each of your directories.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help writing a simple regex for RewriteRule for mod_rewrite in htaccess. So,
I need some help writing an http client. The trouble comes when I try
I need some help writing a regex. I have the following strings, xxx.yyy.wwwwwaaa_IN_123 xxx.rrrttttt_IN_12355
I need help writing a regex with grouping to match the following six input
All, I have the following JSON Data. I need help writing a function in
I need help writing a regular expression to meet the following requirements: start with
I need help in writing a mod_rewrite to allocate users their own personal subdomains.
I need help writing a conditional where clause. here is my situation: I have
Need help writing a script downloads data from google insight using c# this is
I'm new to web programming, so I need some help. I am writing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.