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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:04:10+00:00 2026-05-13T06:04:10+00:00

We have the following mod_rewrite condition/rule but it is returning a 404 error on

  • 0

We have the following mod_rewrite condition/rule but it is returning a 404 error on URLs that merely begin “i” (or “css” for that matter) if they do not equate precisely to our corresponding directories (/i /css etc.)

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|/(i|css|design_and_docs|js|test)/*)
RewriteRule ^(.*)$ /index.php/$1 [L]

This then disallows me from having a route/URI (using CodeIgniter but I don’t think that matters) such as /itemid or /idcommand (just a couple I’ve had need of in the past week)

I can easily modify the RewriteCond as follows to test for a trailing slash but then a request for the /i directory, without the trailing slash, fails whereas it previously worked:

RewriteCond $1 !^(index\.php|robots\.txt|/(i|css|design_and_docs|js|test)\//*)

With the trailing slash /i/ still resolves and that may be good enough for our purposes. But I’d really like /i to still resolve to the corresponding /i directory. So instead of just testing for a trailing slash at the end, I’d like to test for a trailing slash, or the absence of any characters.

How do I do that with a regular expression?

  • 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-05-13T06:04:10+00:00Added an answer on May 13, 2026 at 6:04 am

    Instead of just \/ for the trailing slash, do a subgroup and check for that or the end of string, which is a $: (\/|$)

    RewriteCond $1 !^(index\.php|robots\.txt|/(i|css|design_and_docs|js|test)(\/|$)/*)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mod_rewrite rule: RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1 This works fine in redirecting
I have the following mod_rewrite rule: RewriteRule ^home/ home.php [L] Fairly simple. When I
The following mod_rewrite rule accomplishes the task of rewriting www.domain.com/2011/11/page to www.domain.com/page but breaks
Apache Mod-Rewrite, I have a problem not a error as such but the following
I am trying to use mod_rewrite to generate cleaner urls. I have the following
I have following script that executes all the .reg files in the current directory.
I have following CSS: table tbody tr:last-child td { padding-top: 7px; border-bottom: 0; }
I have the following rewrite rules <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}
I'm having a small problem with mod_rewrite I have the following in my .htacces:
I have the following code and the only redirect that seems to be working

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.