重写 WordPress 规则
我的主题有一个自定义页面,它根据给定的参数显示不同。此页面被设置为网站的主页。 有效的参数组合可以如下:
my_domain/?fa={action}&type={type}
my_domain/?fa={action}&id={type}
my_domain/?fa={action}
我想做的是将这些链接转换为以下内容:
my_domain/fa/{action}/type/{type}
my_domain//fa/{action}/id/{type}
my_domain/fa/{action}
我的 .htaccess 文件现在看起来像这样,但它似乎不起作用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^fa/(.*)/type/(.*)$ /index.php [L]
RewriteRule ^fa/(.*)/id/(.*)$ /index.php?fa=$1&fid=$2 [L]
RewriteRule ^fa/(.*)$ /index.php?fa=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我在这里做错了什么?
谢谢, 拉杜
I have a custom page on my theme that displays differently based on given parameters. This page is set as homepage for the website.
Valid parameters combinations can be as follows:
my_domain/?fa={action}&type={type}
my_domain/?fa={action}&id={type}
my_domain/?fa={action}
What i'm trying to do is to convert these links to the following:
my_domain/fa/{action}/type/{type}
my_domain//fa/{action}/id/{type}
my_domain/fa/{action}
My .htaccess file now looks like this, but it doesn't seem to work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^fa/(.*)/type/(.*)$ /index.php [L]
RewriteRule ^fa/(.*)/id/(.*)$ /index.php?fa=$1&fid=$2 [L]
RewriteRule ^fa/(.*)$ /index.php?fa=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
What am i doing wrong here?
Thanks,
Radu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同样的问题,我使用“Kyle E Gentile”创建的类丢失了链接。
但他的班级在下面。
创建一个文件: add_rewrite_rules.php
然后在你的 funcitons.php 文件中,
可能值得研究一下..
我知道它适用于你的前两个变量 fa &键入但是..
不确定你是否可以重写一点来添加 ID,
Marty
same issue, I used a class created by 'Kyle E Gentile' lost the link.
but his class is below.
create a file: add_rewrite_rules.php
then in your funcitons.php file,
could be worth looking into..
i know it will work for your first two variables, fa & type but..
not sure if you could re-write a little to add the ID,
Marty