简体   繁体   English

WordPress .htaccess不适用于rewriterule

[英]WordPress .htaccess not working for rewriterule

Can we rewrite WordPress page /ghij to show the contents of page /faq , when permalinks are already enabled? 当永久链接已经启用时,我们可以重写WordPress页面/ghij来显示页面/faq /ghij的内容吗?

My page is example.com?page_id=70&category=Footage . 我的页面是example.com?page_id=70&category=Footage After enabling permalink it is showing example.com/video-category?category=Footage . 启用永久链接后,它显示example.com/video-category?category=Footage I want it to look like example.com/category/Footage . 我希望它看起来像example.com/category/Footage

Any help in this will be appreciated. 任何帮助将不胜感激。

Current .htaccess : 目前.htaccess

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

    RewriteCond %{QUERY_STRING} ^page_id=([0-9]*)&category=(.*)$
    RewriteRule ^(.*)$ /%1/%2? [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress 

Works. 作品。 And redirects from: 并重定向:
http://test.com/index.php?page_id=70&category=Footage http://test.com/index.php?page_id=70&category=Footage
To: 至:
http://test.com/70/Footage http://test.com/70/Footage



UPDATED: 更新:

RewriteRule ^(.*)/(.*)$ /index.php?page_id=$1&category=$2 [L]


This rule Works and makes inner redirect (without url change) from: 此规则工作并使内部重定向 (没有URL更改):
http://test.com/70/Footage http://test.com/70/Footage
To: 至:
http://test.com/index.php?page_id=70&category=Footage http://test.com/index.php?page_id=70&category=Footage

i hope the following plugin will help you more 我希望以下插件能为您提供更多帮助

http://wordpress.org/extend/plugins/permalink-editor/ http://wordpress.org/extend/plugins/permalink-editor/

please check this plugin it will rewrite the permalink as you want without any coding knowledge. 请检查此插件,它将根据您的需要重写固定链接,无需任何编码知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM