通过 .htaccess 重写 URL

Rewrite URL through .htaccess

我的网站生成带有前缀 ?Script= 的页面 URL,这不是 SEO-friendly.

我想去掉这个前缀,只保留页面标题。

比如我要转换如下URL:

example.com/?Script=aboutexample.com/about

about 是我网站的关于页面。

我想为所有页面设置一个省略 ?Script= 的规则。

我已经通过使用以下重写规则为我的博客 post 做到了。

RewriteRule ^news/([0-9a-zA-Z_-]+) ?Script=news_view&uid=

这应该适合你。

RewriteEngine on

RewriteRule ^(about)/?$ /?script?= [L]

如果您有更多页面,可以将这些页面添加到模式中

RewriteEngine on

RewriteRule ^(about|page2|page3)/?$ /?script?= [L]