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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:35:53+00:00 2026-05-15T13:35:53+00:00

I am using a .htaccess file to direct requests for a directory to a

  • 0

I am using a .htaccess file to direct requests for a directory to a custom php file that provides info about that directory (and i want the url displayed by the browser to not change).

Here is the relevant part of the .htaccess file.

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /myphp.php?url=%{REQUEST_URI} [QSA,L] 

This works well if you go to a directory and include a trailing slash:

http://domain.com/path/

But without the trailing slash, it doesn’t

http://domain.com/path

The url (shown in the browser) turns into:

http://localhost:8888/path/?url=/path

I’ve tried fixing this by adding a rule above this rule:

RewriteCond %{REQUEST_FILENAME} -D
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L]

But that isn’t working for me.

How can I get .htaccess to add the trailing slash if it is omitted and then act just as if it had been there?

Thank you

Update:
As requested, here is the whole thing.

<IfModule mod_rewrite.c>
RewriteEngine On

#force trailing slashes on real directories
RewriteCond %{REQUEST_FILENAME} -D
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L]

#use the directory viewer on directories without an index page
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /myphp.php?url=%{REQUEST_URI} [QSA,L]  

</IfModule>
  • 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-15T13:35:54+00:00Added an answer on May 15, 2026 at 1:35 pm

    This line:

    RewriteCond %{REQUEST_FILENAME} -D
    

    Should have been:

    RewriteCond %{REQUEST_FILENAME} -d
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to redirect URLs by using the .htaccess file: index.php?i=Dengue-NS1-ELISA-kit---Antigen&id=682&cat=0 to index.php?i=Dengue-NS1-ELISA-kit---Antigen&id=682&cat=17 Notice
hey well I'm trying to change the url structure using the htaccess file and
I want to redirect using .htaccess abc.com/test.php to abc.com/test . but it will execute/display
I have this little .htaccess file: RewriteEngine on RewriteRule ^(.*)$ urlroute.php?q=$1 [E=myvariable:'withthisvalue',B,QSA] To direct
I'm using htaccess to change a file extension from gif to php but it
I am having problem in URL rewriting using .htaccess file, problem is as below.
I'm using a .htaccess file to force all 'example.com' requests to 'www.example.com' The problem
I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache.
I'm using the following in my .htaccess file but it doesn't seem to be
I'm using the following lines of code in my .htaccess file to create redirects.

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.