Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htacces rewrite url - redirect folder to php file

Tags:

.htaccess

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

like image 294
drummer392 Avatar asked Feb 21 '23 09:02

drummer392


1 Answers

Try this

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?sub=$1
like image 77
Nimit Dudani Avatar answered Mar 04 '23 18:03

Nimit Dudani