友好的网址实施wordpress样式

I need some guidance as to the friendly url, which is the best way to implement since. Htaccess, handle with php create the links

if the path is:

http://www.site.com/index.php?op=notice&id=34 convert to http://www.site.com/notice/34/ or http://www.site.com/notice/the-best/

If you already have it. .htaccess:

RewriteRule ^ ([A-Za-z0-9-]+)/?$ index.php? Op = $ 1 [L]

From PHP to generate the right links. Htaccess, enable the slug. Just as we have wordpress, any idea.

Thank you very much

You have to make it so that index.php shows the right content depending on the URI. How this is solved will be different from case to case.

Wordpress just have to see if there's a corresponding post or page, and if so, display content.

First, you need to make sure your apacheserver has the mod rewrite enabled

-> sudo a2enmod rewrite

Then, why not use the .htaccess code, Wordpress uses?

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

Your php-file needs to pickup the url and translate it into something you can use, for example a database call?

function curPageURL()
{
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on")
    {
        $pageURL .= "s";
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    }
    else
    {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}