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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:20:33+00:00 2026-05-24T20:20:33+00:00

How can I add a trailing slash to: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php I

  • 0

How can I add a trailing slash to:

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php

I have tried with:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+[^/])$ $1/ [R]

But it’s not working

  • 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-24T20:20:34+00:00Added an answer on May 24, 2026 at 8:20 pm

    See the detail/description line for the CondPatterns -d and -f for RewriteCond. See how it says “tests whether or not it exists, and is a regular file”? That is expensive and does not scale well at all. Do you really care if it’s “a regular file”? No, you only care if it looks like a file. (matches the filename.extension pattern) So, I’m going to improve your Rewrite while I’m at it.

    See the detail/description for the ‘last|L’ flag for RewriteRule. See how it says “don’t apply any more rewrite rules”? I bet that’s what you want isn’t it? You want either index.php to be used when a request doesn’t match the extension of a static asset, OR you want to put a slash on the end of a request that doesn’t match the filename.extension pattern. Not both.

    Here’s how you do that:

    # turn on matching
    RewriteEngine on
    
    # 1st rule block. If any of the conditions don't apply skip over this block to the next.
    # condition: uri ends with filename.extension
    RewriteCond %{REQUEST_URI}  [^/.]+\.[^/.]+$
    # condition: uri doesn't end with a desired extension
    RewriteCond %{REQUEST_URI}  !\.(js|ico|gif|jpg|png|css|html)$ [NC]
    # rewrite the request to be for index.php and don't apply any more rules
    RewriteRule -  index.php [L]
    
    # 2nd rule block. If any of the conditions don't apply skip over this block to the next.
    # condition: uri doesn't end with a slash
    RewriteCond %{REQUEST_URI}  !/$
    # condition: uri doesn't end with filename.extension
    RewriteCond %{REQUEST_URI}  !/[^/]+\.[^/.]+$
    # rewrite the request to be appended with a slash
    RewriteRule (.*)  $1/ [R=301]
    

    This is a very good answer considering that you didn’t tell us want you are trying to do. If you want a better answer, you’ll need to give us more info than “I copied and pasted 2 code snipets together, but it’s not working.”


    Update: I hastily threw together an edit to this answer based on cornegigouille’s answer. Here is a bash shell transcript of the proof I did to test it. Let me know if you see a bug.

    #bruno:~$ (
    for str in asdf asdf.css asdf.min.css; do
        echo -e "\n## $str ##"
        echo /brunobronosky1/$str | grep -E '/[^/.]+\.[^/.]+$' || echo '[no match]'
        echo /brunobronosky2/$str | grep -E '/[^/]+\.[^/.]+$' || echo '[no match]'
        echo /cornegigouille/$str | grep -E '/[^/.]+(\.[^/.]+)+$' || echo '[no match]'
    done
    )
    
    ## asdf ##
    [no match]
    [no match]
    [no match]
    
    ## asdf.css ##
    /brunobronosky1/asdf.css
    /brunobronosky2/asdf.css
    /cornegigouille/asdf.css
    
    ## asdf.min.css ##
    [no match]
    /brunobronosky2/asdf.min.css
    /cornegigouille/asdf.min.css
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a trailing slash to urls using PHP. It can't be
I'd like to add a trailing slash to any url's that match a valid
Ok lets say I have a URL example.com/hello/world/20111020 (with or without the trailing slash).
I now have : RewriteEngine On RewriteCond %{HTTP_HOST} !^domain.co.uk$ [NC] RewriteRule ^(.*)$ http://domain.co.uk/$1 [L,R=301]
I can add and remove the last line in my dynamic form and calculate
I can add a normal rightBarButton to my navigation without a problem but now
I can add a Conditional statement to a breakpoint, for instance arg0.startsWith(something) but i'd
We can add an image to an photo album using UIImage *img = [UIImage
Can someone please direct me on how I can add something similar to inputAccessoryView
I wrote library which can add and update objects in salesforce. I use beatbox

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.