公共url不同于后台url


public url different to behind the scenes url

如何允许用户导航到此urlexample.com/aaron cole about,并在幕后将其更改为此url为example.com/about?id=52,但仍在浏览器上显示此urlexample.com/aaron cole about

在我的.htaccess文件上尝试过这个,但我似乎不起作用:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !'.php$
RewriteRule ^(.*)$ $1.php [L,QSA]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/aaron-cole-about$ /about?id=52 [L]

现已修复

您只需要重新排序规则即可。

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/aaron-cole-about$ /about?id=52 [L]
RewriteRule ^(.*)$ $1.php [L,QSA]

发生的事情是,它与(.*)相匹配—又称匹配任何东西—规则,这会使您的更具体的规则无法访问。