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

  • Home
  • SEARCH
  • 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 6574777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:18:14+00:00 2026-05-25T15:18:14+00:00

My page runs on php for no js-users. For users with javascript on I

  • 0

My page runs on php for no js-users. For users with javascript on I load all content dynamic fromt the index in combination with the hashchangevent. So the links all look like http://www.page.com/#page.php, with a # before it. If the user types it in that way every thing works like charm and the content is being loaded over the index.php

But if a user would enter http://www.page.com/page.php the page of course ends up on the php page and the dynamic page will of course not work any more except the user will hit the index page and go on navigate from that. So that’s not a cool way.

My Question:

How can I redirect user from:

http://www.page.com/page.php

to

http://www.page.com/#page.php

when they typed in http://www.page.com/page.php in the Browser

Of course only with javascript. The Page should work without javascript on normally with php.

Thank you.

  • 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-25T15:18:15+00:00Added an answer on May 25, 2026 at 3:18 pm

    When the page loads, change the window.location to the desired URL by deconstructing and reassembling the URI. Unfortunately, you’ll have to include this on every page (i.e., page.php) on which you’d like the redirect to happen.

    $(document).ready(function () {
        // Insert the pathname after the hash, but skip the leading '`'
        window.location = "/#" + document.location.pathname.slice(1);
    });
    

    It’s slightly less clean, but you could also remove the window.location bit from .ready() entirely. This would effect an small performance improvement.

    If you want the hash-redirect to affect only the last element of the current path, use the code below, instead.

    window.location = "./#" + document.location.pathname.split('/').pop();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 2.0 framework ASP.Net page that runs in our controled environment (IE
I have a simple jQuery code that runs on a web page that has
When you create an ASP.NET page with no controls and runs it, a view
I wanted to create a page with a simple button which runs away from
I need to create an ASP page (classic, not ASP.NET) which runs remote shell
The following code converts a PDF page into a JPEG. It runs as expected
I have a web page, used for admin purposes, which runs a task (image
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I am using jQuery to load the search results from a php class when
I set the users timezone in the header of my page, in my setting

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.