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 7880211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:05:24+00:00 2026-06-03T04:05:24+00:00

I’m trying to write a couple of rewrite rules for my drupal site in

  • 0

I’m trying to write a couple of rewrite rules for my drupal site in its .htaccess file and it doesn’t seem to work at all. My lack of prior knowledge and experience in regex and mod_rewrite doesn’t seem to help the cause either.

The URLs I’m trying to rewrite are as follows

Source:

http://www.mydrupalsite.com/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithspecialchars/Keyword1/Keyword2/UNIQUEID?queryparam1=somenumber

Destination:

http://www.mydrupalsite.com/legacystuff/UNIQUEID

My .htaccess mod_rewrite code is

  RewriteEngine on
  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  #This is the only rule written by me others are drupals
  RewriteRule ^(.*)/(.*)/(.*)/(.*)/Keyword1/Keyword2/([0-9]*)?$ legacystuff/content/$5 [R=302]
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

My understanding and implementation based on some quick browsing on tutorials was the first four (.*) would match with the four alphanumericspecialchars in the URL, keyword1 and keyword2 would remain constant so i could match them as such, the unique numeric id which is actually required for my destination URL (param $5 in the destination) would be captured by ([0-9*])?. I use the following vhost in my httpd.conf of my local environment

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/mydrupalsite"
ServerName mydrupalsite.com
</VirtualHost>

My trouble is that the redirect from the source to destination URL does not occur after restarting my local server and clearing the cache. Any help on where I went wrong and how to make it right would be really appreciated.

  • 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-03T04:05:26+00:00Added an answer on June 3, 2026 at 4:05 am

    Finally got it working, added the RewriteBase for my virtual host setting and placed my RewriteRule underneath it with the trailing ? in my destination to ignore query string and the L flag. Setting RewriteLog in my httpd.conf helped understand things from a better perspective. Hopefully this helps someone else new to .htaccess in drupal.

    RewriteBase /
    RewriteRule ^(.*)/(.*)/(.*)/(.*)/Keyword1/Keyword2/([0-9]*)?$ legacystuff/content/$5? [R=301,L]  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm trying to select an H1 element which is the second-child in its group
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.