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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:43:45+00:00 2026-06-16T03:43:45+00:00

In my domain example.com , I want to put all page files in a

  • 0

In my domain example.com , I want to put all page files in a directory at root for example named file. So for example I put about.php the file directory and want to let users to access this page with this URL : example.com/about
or for example put user directory in the file directory and put login.php in it , and want to let users to access it with : example.com/user/login
In fact I want to remove .php and the file from the URLs.

AND

If those files don’t exist , it should load a default file like index.php at root. for example the URL example.com/blabla should be mapped to the index.php

In fact , I want to make two conditions in mod rewrite with the mentioned priority.

notice : of course I should be able to use variables like $_GET at files like about.php

UPDATE : in summary , it should work with this logic :

if the URI isn't a file or directory{
    if file/URI.php is a file
        load file/URI.php
    else
        load index.php
}

some body gave an answer to use ErrorDocument 404 index.php , but it’s a really bad idea (and now has deleted his answer !)

Thanks for your help…

  • 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-16T03:43:46+00:00Added an answer on June 16, 2026 at 3:43 am

    A conditional rewrite (if the pages exist) sounds like a bad and complicated idea, if it even is possible.

    I would rewrite everything to /index.php and control everything from there:

    • If the components of the url lead to an existing page, use / include that content;
    • If no valid page is found, present your original index content.

    Example redirect rules for your situation:

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^.*$ /index.php?id=$1 [QSA,L]
    

    Will include the requested path in id and append the variables from the original query string (the QSA flag).

    More specific for your /user/login example would be:

    RewriteRule ^([\w-]+)/([\w-]+)$ /index.php?path=$1&file=$2 [QSA,L]
    
    • [\w-+] : any word character (including _) and the -
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to point a subdomain such as: example.domain.com to a URL like: domain.com/something/this.php
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have a page, URI looks like this: http://domain.example.com/Profiles/Profile.aspx?username=blah#blahtab When that fragment (#blahtab) is
I have a site that sits in a directory on a domain: http://www.example.com/site/ I
I have a domain for example http://example.com and another domain http://reallylargerdomain name.com I want
I have a Drupal website. It's domain is example.com. I want domains: mysite.com and
I have a domain example.com and mainexample.com- i want a example.com to point to
Let's say I have the domain http://www.example.com . When I browse to http://www.example.com/12345 it
I want the following to redirect to https://www.domain.com http://example.com http://www.example.com I used the default
I've got a domain example.com and an alternative of some-example.com . I'm trying to

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.