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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:44:49+00:00 2026-06-13T11:44:49+00:00

I am building an ajax-driven website that uses html5 pushState() to preserve its url

  • 0

I am building an ajax-driven website that uses html5 pushState() to preserve its url structure and facilitate reliable page reloads, etc. For this,I have set up my htaccess in such a way that any directory path that begins with an uppercase letter and has no trailing slash is redirected to some

“domain.com/index.php?page=Directorypath”

So right now my requests are translated as:

domain.com/Folder => domain.com/index.php?page=Folder

domain.com/Folder/ , domain.com/folder, domain.com/folder/ => (default, no rewrite)

This is done by my .htaccess file (located at domain root) and has the code :

# Enable Rewriting
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^((/?[A-Z][A-Za-z0-9]*)+[^/])$
RewriteRule ^((/?[A-Z][A-Za-z0-9]*)+[^/])$ index.php?page=$1

This worked fine until I added a blank directory named “Folder” and visited “domain.com/Folder” on my browser.
Previously, “domain.com/Folder” was giving me the expected content (“domain.com/index.php?page=Folder”) and “domain.com/Folder/” was giving me a 404 error, as expected since there was no directory named “Folder” in the document root.

Now my expected result was:
Browser shows “domain.com/Folder” in the url bar and server delivers the content of “domain.com/index.php?page=Folder” (same as the case when “Folder” did not exist)

But instead:
Browser shows “domain.com/Folder?page=Folder”

Can someone point out what I am doing wrong over here? And, if possible, how I could correct it?

*I have no other htaccess files in any other directory.
Edit: the scheme seems to be working fine when I force a permanent redirect [R=301], but unfortunately that changes the url in browser’s address bar.

  • 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-13T11:44:50+00:00Added an answer on June 13, 2026 at 11:44 am

    Finally, I figured it out!
    The headache was caused by apache’s built in DirectorySlash configuation, which was adding the trailing slash silently if the directory existed.
    So I fixed it by turning it off. But when I thought about it more, I felt that it is actually a useful redirection, so I hard coded my htaccess to add trailing slashes for all other directories that doesn’t start with an uppercase letter

    So here is my final htaccess file:

    RewriteEngine On
    DirectorySlash Off
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^((/?[A-Z][A-Za-z0-9]*)+[^/])$ 
    RewriteRule ^((/?[A-Z][A-Za-z0-9]*)+[^/])$ index.php?page=$1 [L]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^([a-z0-9][A-Za-z0-9/]*[^/])$ $1/ [R,L]
    

    Hope this might help others with similar troubles

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

Sidebar

Related Questions

I am building a web site that uses AJAX to load its different pages
I am building a GAE site that uses AJAX/JSON for almost all its tasks
I'm building a composite control that uses the telerik ajax controls as it's inputs,
i'm building a page that is dinamically loaded with ajax. This is what the
I building a simple, 7 page, database driven, website, and I would like to
I'm building an application that uses a lot of ajax. Most anti-CSRF solutions revolve
I'm building an AJAX navigable site (code taken from CSS-Tricks ) that uses regular
I am building an AJAX application that uses both HTTP Content and HTTP Header
I'm building a contact form that uses ajax via jQuery to fetch a CAPTCHA
I am building an AJAX powered website which uses the Really Simple History (RSH)

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.