How to handle all urls from 1 page using PHP?

I would like to redirect all the URLs from the webpage (whatever after the domain name) to one webpage that will parse the full URL and show a good page and information. I know that this is possible using Mod_Rewrite and using some PHP function to get the url, but I can not find a good web page showing the steps and how to execute it.

My questions:

1) Do you have any link that I can read about this?

2) Do you think this is a good way to do this, I am transforming a website that needs to be more search engine friendly and requires good URL formatting?

+3
source share
1 answer

Try:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

This will redirect everything that does not exist to index.php.

This is called the front controller pattern .

+5
source

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


All Articles