Click here to Skip to main content
15,304,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have quite a simple site structure, with each page having a separate html file.

These can have any number of subfolders before the final file;

However, I need to dynamically generate these HTML files. That means I need PHP files to echo the HTML content, but at the same time I'd like to remove the whole file structure on the disk. My idea is to re-route the requested pages to a single PHP file, which echoes the corresponding content.

So for example:

should become, in the background and NOT shown in the browser:

So I got to writing a .htaccess file, but it's not passing the path properly:
RewriteEngine On
RewriteBase /

RewriteRule ^(.+)$ find.php?path=$1 [L,B]

I've chosen those flags because:

• Nothing past this rule should be considered
• I was hoping B would escape the path properly, but it doesn't.

What I have tried:

Richard Deeming 30-Aug-18 11:35am
You'll want the QSA flag[^] if you need to append the original querystring to the rewritten URL.

I don't think you'd need the B flag[^] based on the description.

Do you have an example of a path that's not being passed properly (the original path, and the rewritten URL)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900