Htacces rewrite url - redirect folder to php file

I want to redirect or rewrite subdirectories to PHP files

For instance:

http://www.domain.org/contact 

:

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

I would REALLY want PHP to just read domain.org/contact as domain.org/index.php?sub=contact, but if it just redirects this path, I will be happy! I searched a lot of solutions using .htaccess, but they are unclear or I can not get them to work specifically for what I am trying to do

thanks

+4
source share
1 answer

try it

 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /index.php?sub=$1 
+7
source

Source: https://habr.com/ru/post/1397946/


All Articles