wordpress - 漂亮的 url 与 .htaccess?

标签 wordpress .htaccess url-rewriting seo pretty-urls

我刚刚创建了一个新的 wordpress 页面模板,在其中运行一些 php 和 mysql 脚本,我想将 mod 重写应用于它的子页面。

例如我生成了以下链接:

http://www.quotist.com/quotes-by-authors.html?letter=D

我怎样才能把它变成类似这样的东西:

http://www.quotist.com/quotes-by-authors/letter/d/

在我的 htaccess 中,我有 wordpress 生成的默认代码 ...

有人知道如何实现吗?

最佳答案

试试这个:

Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

RewriteCond %{QUERY_STRING} ^(letter)=(\w)$ [NC]
RewriteRule ([^.]+)\.html http://www.quotist.com/$1/%1/%2? [L,R=301]

RewriteCond %{REQUEST_URI} ^/([\w-]+)/(letter)/\w/? [NC]
RewriteRule ^ /%1.html?%2=%3 [L,QSA]

关于wordpress - 漂亮的 url 与 .htaccess?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9309380/

相关文章:

apache - 将子文件夹重定向到根目录并将其隐藏在 url 中

windows - Url 重写不会安装在 Windows 10 IIS 10 上

iphone - 如何通过短信发送网址?

css - 寻找一种使用 wordpress 在 css 中编辑网站背景的方法

WordPress 主题无法从本地正确导入到在线

javascript - 如果在几秒后单击正文,如何触发 javascript 函数?

javascript - 如何使用 wp_enqueue_script 加载 js?

regex - .htaccess RewriteRule 使用查询字符串重写条件,但不将查询字符串添加到最终网址

php - 管理员登录页面上的 WordPress 403 错误

c# - 正则表达式解析字符串url链接