字preSS的.htaccess重写URL [英] wordpress .htaccess rewrite url

查看:248
本文介绍了字preSS的.htaccess重写URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了我的话,preSS现场问答部分。我有W3的总缓存安装在我的网站。 我希望把测验上

I am developing quiz section for my wordpress site. I have W3 total cache installed on my site. I want to put quiz on

http://www.example.com/quiz/seo-friendly-标题/ ID

和重写的htaccess的URL重定向到

and rewrite htaccess to redirect the url to

http://www.example.com/ ?测验题=搜索引擎友好的标题和放大器;竞猜-ID = ID

测验部分被开发成字preSS模板和空白页使用此模板制作。

The quiz section is developed as wordpress template and a blank page is made using this template.

这是的.htaccess我写的。

This is .htaccess I wrote.

< IfModule mod_rewrite.c>     RewriteEngine叙述上     的RewriteBase /     重写规则^测验/([\ w \ D \ - ] +)/(\ D] +)1 $测验题= $&放大器;竞猜ID = $ 2 [L]     重写规则^指数\ .PHP $ - [L]     的RewriteCond%{} REQUEST_FILENAME!-f     的RewriteCond%{} REQUEST_FILENAME!-d     重写规则。的index.php [L] < / IfModule>

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^quiz/([\w\d\-]+)/(\d]+)$ quiz?title=$1&quiz-id=$2 [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

任何形式的帮助将是AP preciated!

Any form of help would be appreciated!

推荐答案

你去设置和固定链接?如果是,它不是你想在这里看看有什么

Did you go to settings and permalinks? if yes and its not what you want have a look here

<一个href="http://stackoverflow.com/questions/24985550/how-to-hide-a-page-from-being-seen-in-word$p$pss-backend-and-frontend/24985961#24985961">how从被人看见在字preSS后端和前端隐藏页面

add_action('init', 'a_add_rewrite_rule');
function a_add_rewrite_rule(){
// add_rewrite_rule(REGEX url, location, priority (i.e. top is before other rewrite rules)
// I created a custom post type for this plugin called market -- replace post_type with whatever you want 
//basically tell wordress to add a query var if sidebar is added to url.
add_rewrite_rule('^sidebar?','index.php?is_sidebar_page=1&post_type=market','top');
}

// register a query var
add_action('query_vars','market_set_query_var');
function market_set_query_var($vars) {
array_push($vars, 'is_sidebar_page');
return $vars;
}

// associate a template with your quer_var 
add_filter('template_include', 'market_include_template', 1000, 1);
function market_include_template($template){
if(get_query_var('is_sidebar_page')){
   $new_template = (theme or plugin path).'/pages/yourpage.php'; // change this path to your file 
if(file_exists($new_template))
    $template = $new_template;
} 
return $template;
}

这篇关于字preSS的.htaccess重写URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆