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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:57:19+00:00 2026-05-24T08:57:19+00:00

I am trying to figure out Apache’s Mod Rewrite and so far it’s not

  • 0

I am trying to figure out Apache’s Mod Rewrite and so far it’s not working. Here is what I am trying to do.

I have an index.php in the root directory of my site that is a template for all pages. I want to be able to organize my files in directories and the query string will have slashes.

So…

http://www.example.com/page.html

should be…

http://www.example.com/index.php?url=page

and…

http://www.example.com/directory/page.html

should be…

http://www.example.com/index.php?url=directory/page

I’ve got that working but I want to be able to go n directories deep…

http://www.example.com/directory1/directory2/page.html

should be…

http://www.example.com/index.php?url=directory1/directory2/page

I know I could just put a bunch of rewrites for however many directories I deep I want to go, but is there a single line RewriteRule that will put anything after the first / will be considered a query string?

This is what I have so far…

RewriteEngine on
RewriteRule ^([a-z-]+)\.html$ index.php?url=$1
RewriteRule ^faculty/([a-z-]+)\.html$ index.php?url=faculty/$1

Behind the scenes, PHP is including the file that is in the location that the url is specified.

  • 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-24T08:57:19+00:00Added an answer on May 24, 2026 at 8:57 am
    1. This is bad idea to include file which name was passed from user. At least implement very STRONG validation, otherwise prepare to be hacked.

    2. If you still want to use this — here is the rule:

      RewriteRule ^(.+)\.html$ index.php?url=$1 [QSA,L]

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

Sidebar

Related Questions

I am trying to figure out how to use Apache Commons IO DirectoryWalker .
trying to figure out why this is happening - I have an input text
Trying to figure out how to type (via events not set the value) on
I am trying to figure out this error Could not load JDBC driver class
I'm trying to figure out why the mail function in PHP fails when called
I'm using Apache Mod RewriteRule to deal with dynamic URLs. And trying to figure
I'm trying to figure out how to get log4j working in my project. I
I've spent the day trying to figure out a strange problem. I have a
I've spent quite a while trying to figure this out. I am working on
Basically, I'm trying to figure out how PHP can be called from a web

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.