0

私はワードプレスのかなりのパーマリンクを使用しています、私の.htaccessファイルは次のようになります:

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

# END WordPress

次のようなURL変数を含むインデックスページを表示するフォームを使用しています。

http://www.nafham.com/?edu_year_selectionreal=79&semester_selectionreal=15&subject_selectionreal=80

次のようにURLを表示したいのですが。

http://www.nafham.com/79/15/80

そうすることは可能ですか?そして、ワードプレスがすでに適用している書き換え条件で物事がうまくいかないようにするためにこれを行うための最良の方法は何ですか?

4

3 に答える 3

3

リライトはすでに設定されているので、必要なのはindex.phpのURLを解析することだけです。

if (preg_match("#(\d+)/(\d+)/(\d+)#", $_SERVER['REQUEST_URI'], $regs)) {

    $edu_year_selection_real = $regs[1]
    $semester_selectionreal = $regs[2];
    $subject_selectionreal = $regs[3];
}
于 2012-04-15T10:53:50.933 に答える
0

smthを追加します。.htaccessにこのように:

RewriteRule ^/([0-9-]+)/([0-9-]+)/([0-9-]+)$ index.php?var1=$1&var2=($2)&var3=($3) [L]
于 2012-04-15T10:57:49.403 に答える
0

Wordpressでカスタム書き換えルールを設定する必要があります。そうしないと、Wordpressはエラーページに移動します。

カスタム書き換えルールを設定する例を次に示します。

      <?php

  add_filter('rewrite_rules_array', 'insert_custom_rules');
  function insert_custom_rules($rules)
  {
$newrules = array();
$newrules['(.+?)/(.+?)/(.+?)/?$'] =
'index.php?edu_year_selectionreal=$matches[1]&semester_selectionreal=$matches[2]&subject_selectionreal=$matches[3]';
return $newrules + $rules;
  }
  ?>

これがお役に立てば幸いです。

于 2012-04-15T13:59:15.587 に答える