What is a good way to have a SEO URL system built up in PHP?

前端 未结 3 1258
遥遥无期
遥遥无期 2021-02-11 07:16

I want to have \"pretty\" and SEO oriented URLs in my site.

I\'ve build up my own tiny framework for this site and almost everything is complete now.

One thing I

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-11 07:27

    You'll need an .htaccess file (but you won't need to change it each time you add a page):

    RewriteEngine On 
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
    

    Now in your index.php you can access the requested url in $_GET['url'], map it to the correct file and then include it.

    Note: Put the RewriteBase comment in there in case you need to uncomment it as some configurations require this.

提交回复
热议问题