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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:27:27+00:00 2026-06-16T21:27:27+00:00

Can someone help me understand this code? # Remove trailing ? RewriteCond %{THE_REQUEST} ?

  • 0

Can someone help me understand this code?

# Remove trailing ?
RewriteCond %{THE_REQUEST} ? HTTP [NC] 
RewriteRule .? /%{REQUEST_URI}? [R=301,L]

Basically I have a site http://www.example.com that is generating a link to http://www.example.com/index.cfm? I need it to redirect to http://www.example.com for SEO duplication purposes. I managed to remove the index.cfm but the ? still stays there (www.example.com/?). The trailing slash is also removed just fine if it’s the last character. I found this rule online but I’m getting a “RewriteCond: bad flag delimiters” alert in apache and it doesn’t do anything.

I also have some pages like http://www.example.com/index.cfm?term=test for searching so I just want to get rid of the trailing question mark and not when I do have a query attached to it.

The error is in the RewriteCond. I need help understanding the condition and why it doesnt work not just the answer to it.

Just in case here is the entire htaccess:

RewriteEngine On
Rewritebase /

# remove trailing index.cfm
RewriteRule ^index.cfm(\?)?$ / [R=301,L]

# SEF URLs
SetEnv SEF_REQUEST false
RewriteRule ^[a-z\d\-]+/[a-z]\d+/? /index.cfm/$0 [NC,PT,QSA,E=SEF_REQUEST:true]
RequestHeader add SEF-Request %{SEF_REQUEST}e
RewriteCond %{HTTP:SEF_REQUES} ^true$ [NC]
RewriteRule . - [L]

# Remove trailing ?
RewriteCond %{THE_REQUEST} ? HTTP [NC] 
RewriteRule .? ^%{REQUEST_URI}? [R=301,L]

NOTE: I did search online/stackoverflow before posting and did not find a solution to my problem.

EDIT: Also I noticed that my RewriteRule ^index.cfm(\?)?$ / [R=301,L] is removing the index.cfm even if it’s not the last thing in the url resulting in a 404 when i try searching something (www.example.com/index.cfm?term=test) If someone could correct me and EXPLAIN that would be great. Thanks you.

EDIT2: http://www.example.com/index.cfm?term=test&a=dh&j=dhjsi should NOT be redirected.
http://www.example.com/a/b/d/f/h/w/d should not be redirected.
http://www.example.com/index.cfm? and http://www.example.com/index.cfm should be redirected to http://www.example.com.

  • 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-16T21:27:28+00:00Added an answer on June 16, 2026 at 9:27 pm
    RewriteCond %{THE_REQUEST} ? HTTP [NC] 
    RewriteRule .? ^%{REQUEST_URI}? [R=301,L]
    

    Isn’t going to work, because ? is a reserved character for regular expressions and you’d need to escape it along with the space. Try:

    RewriteCond %{THE_REQUEST} \?\ HTTP [NC] 
    RewriteRule ^/?(index\.cfm)? /? [R=301,L]
    

    Additionally, you want this rule under your # remove trailing index.cfm rule, and not at the very bottom.

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

Sidebar

Related Questions

Can someone help me understand this ancient code? $a = 00040000000002; $n = sscanf($a,xxxxxxx,$r[7],$r[6],$r[5],$r[4],$r[3],$r[2],$r[1]);
Can someone help me understand this piece of code: char *line = new char[2048];
Can someone please help me understand why this code is not working? $('#quick-search-header.widget-title').css('background-image', 'url(dd_includes/images/icons/sliding-menu-arrow-right.gif)');
Can someone help me understand this line of jquery code?: $(this).find('input[type=submit]:not(.cancel), button').click(function () I'm
Can someone explain help me understand how the this bit of code works? Particularly
Can someone help me understand how to write this case statement properly its not
I was wondering if someone could help me understand what this code is doing.
Can someone help me understand way fo creating xaml code for TreeView component and
Can someone please help me understand why this bool isn't saving? Here is my
(Specifically, I'm using Backbone Model events) Can someone help me understand how javascript events

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.