Jump to content

Recommended Posts

I currently redirect all non-file, non-directory HTTP requests to the front controller of my MVC framework with this bit of mod-rewrite:

 

<IfModule mod_rewrite.c>
   RewriteEngine on

       # if there's only one URL bit, load it as a file
       # this is for things like login.php, contact.php etc.
       RewriteRule ^([^/]+)/$ $1.php

       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d

       # route all remaining URL's to the front controller
       RewriteRule .* index.php [L]
</IfModule>

 

However, I need to add a trailing slash to my URLs. Since the typical way to add a trailing slash is to use a 301 redirect to the URI with the slash concatenated, it conflicts with my redirect to the front controller (you can only redirect once)...

 

Any ideas on how I can add the slash before it is redirected, so that the URI carries forward to the front controller with the trailing slash in tact? Not having the trailing slash is screwing with my breadcrumb class further down the code road...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.