4

I want to redirect or rewrite sub directories to PHP files

Such as:

http://www.domain.org/contact

to this:

http://www.domain.org/index.php?sub=contact

I would REALLY like it is PHP could just read domain.org/contact as domain.org/index.php?sub=contact, but if it just redirects that way I'll be happy! I've searched for many solutions using .htaccess, but they are unclear or I can't get them to work specifically for what I am attempting to do

Thanks

1 Answer 1

8

Try this

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?sub=$1
Sign up to request clarification or add additional context in comments.

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.