1

I am creating a PHP project, and the folder structure looks something like:

includes/ 
pages/
config/

In theory, all of the pages will go into the pages folder. But, whenever someone visits the website, on a specific page: (i.e.) www.mysite.com/help I want it to look inside the pages/ folder, rather than thinking it is on the root of the document.

Can I achieve this using PHP / .htaccess - I have googled this problem and cannot see any relevant infomation

3 Answers 3

1

You can use the following rule in /root/.htaccess :

RewriteEngine on

#if "/document_root/pages/foo" is an existent file
RewriteCond %{DOCUMENT_ROOT}/pages/$1 -f
#rewrite /foo to /pages/foo
RewriteRule ^(.*)$ /pages/$1 [NC,L]
Sign up to request clarification or add additional context in comments.

Comments

1

Apache supports URL rewriting as explained here: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Comments

0

.htaccess

RewriteEngine on
RewriteRule ^/?help/?(.*) /pages/$1  [L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.