字preSS的.htaccess重写URL重写、preSS、htaccess、URL

2023-09-02 11:40:38 作者:哼、要你管!

我开发了我的话,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/([wd-]+)/(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

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;
}