How to change appearance of URL from within a PHP script

前端 未结 2 831
[愿得一人]
[愿得一人] 2020-12-20 05:50

I have some PHP and HTML in the same file, and I am not exactly sure how to make the URL appear as the name of that page.

Here is an example of what I would like to

2条回答
  •  [愿得一人]
    2020-12-20 06:08

    What you need is to learn more on how .htaccess work.

    Here is a good link that got me started:

    .htaccess tricks and tips

    Update:

    Here is a very common practice in many framework where all requests are sent to index.php, and from there you use php to serve the correct page:

    
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://www.site.com/index.php [L,R=301]
    
    

提交回复
热议问题