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

  • Home
  • SEARCH
  • 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 ^home/ home.php [L] Fairly simple. When I
I have the following mod_rewrite rule: RewriteRule ^([^/.]+)/?$ search.php?action=procedure&procedureName=$1 This works fine in redirecting
I'm looking to convert the following mod_rewrite rule to the Nginx equivalent : RewriteRule
I have the following mod_rewrite: Options +FollowSymLinks RewriteEngine On RewriteRule ^register index.php?page=register The url
I have the following .htaccess rule: RewriteEngine on RewriteRule ^(.*) http://www.server2.com/index.php?action=$1 I need to
By checking my error logs, I found that i have a link to http://site.com/javascript:;;
I have the following mod_rewrite within my .htaccess file: RewriteEngine On RewriteBase / RewriteCond
I have been having some trouble getting the following to work: <IfModule mod_rewrite.c> DirectoryIndex
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;

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.