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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:56:57+00:00 2026-06-04T19:56:57+00:00

So I’m trying to get mod_rewrite to do a few different things, and I’m

  • 0

So I’m trying to get mod_rewrite to do a few different things, and I’m not quite there with it. I’d like to:

  1. Remove file extensions from the URLs (in this case, .shtml)
  2. Rewrite certain URLs like so:

    /dashboard       -> /ui/dashboard/index.shtml
    /dashboard/      -> /ui/dashboard/index.shtml
    /dashboard/list  -> /ui/dashboard/list.shtml
    /dashboard/list/ -> /ui/dashboard/list.shtml
    /workspace       -> /ui/workspace/index.shtml
    /workspace/      -> /ui/workspace/index.shtml
    /account/manage  -> /ui/account/manage.shtml
    /account/manage/ -> /ui/account/manage.shtml
    
  3. Either add or remove a trailing slash ( I don’t care which, as long as it’s consistent)

What I currently have gets me about 90% of the way there. In my .htaccess file, I’ve got the following:

DirectoryIndex index.shtml index.html index.htm

<IfModule mod_rewrite.c>

  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase /

  # Get rid of the /ui/ in the URLs
  RewriteRule ^(account|workspace|dashboard)([a-zA-Z0-9\-_\.\/]+)?$ /ui/$1$2 [NC,L]

  # Add the trailing slash
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
  RewriteRule ^(.*)$ $1/ [R=301,L]

  # Remove the shtml extension
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.shtml -f
  RewriteRule ^([^\.]+)/$ $1\.shtml

</IfModule>

Now the issues I’m running into are twofold:

First, if I try to access one of the index pages outlined in the directories listed in step 2 above, as long as I do it with a trailing slash, it’s fine, but if I omit the trailing slash, the URL rewrites incorrectly (the page still loads, however). For example

/dashboard/   remains /dashboard/ in the address bar.
/dashboard    rewrites to /ui/dashboard/ in the address bar.

How can I get these index.shtml pages to keep the address bar consistent?

Second, when I try to access a page other than the directory index in one of the rewritten directories, and I include a trailing slash, it gives me a 404 error. For instance:

/dashboard/list/

throws the 404 error:

The requested URL /ui/dashboard/list.shtml/ was not found on this server.

Any help to get this working properly that you can offer is much appreciated.

  • 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-04T19:56:58+00:00Added an answer on June 4, 2026 at 7:56 pm

    So I’ve figured out an approach that works for what I need. Here’s the .htaccess I came up with, commented inline:

    # Match URLs that aren't a file
    RewriteCond %{REQUEST_FILENAME} !-f
    
    # nor a directory
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # if it's the index page of the directory we want, show that and go no further
    RewriteRule ^(account|workspace|dashboard)/?$ /ui/$1/index.shtml [L]
    
    # If we've gotten here, we're dealing with something other than the directory index.
    # Let's remove the trailing slash internally
    # This takes care of my second issue in my original question
    RewriteRule ^(.*)/$ $1 [L]
    
    # Do the rewrite for the the non-directory-index files. 
    RewriteRule ^(account|workspace|dashboard)([a-zA-Z0-9\-_\.\/]+)?$ /ui/$1$2 [L]
    

    Not sure if this is the most efficient way to do this, but it’s working for my needs. Thought I’d share it here in case it helps anyone else.

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

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace

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.