web-dev-qa-db-ja.com

add_rewrite_ruleはWordpressで効力を発揮しませんか? .htaccessファイルが更新されない

私は一日中Wordpressで動作するように自分自身の書き換えを取得しようとしましたが、私は単純に何かを動作させることができません。私はいろいろな方法を試してみましたが、.htaccessファイルの更新は何もないので、この時点で何が間違っているのかはわかりません。これは例えば私が試したワードプレスのマニュアルで見つけたが、それは動作しません。 https://codex.wordpress.org/Rewrite_API/add_rewrite_rule 。書き換えをフラッシュする必要があると聞いたので、flush_rewrite_rules()を追加してみました。 functions.phpファイルにもありますが、違いはありません。また、ワードプレスのパーマリンクも更新して、そのようにして更新しています。しかし、それでも.htaccessファイルには何も起こりません。それで私は何をしますか?ちなみに、私はウェブホテルのサーバーホストサービスを使っているので、私は自分自身で "深い"サーバー設定を変更することはできません。

私はWP Fastest Cacheプラグインを使用しています。これは.htaccessファイルに多く含まれています。それが干渉しないかと私は考え始めましたが、私はそうは思いません。何をすればよいかわかりません。リンクを機能させるために、$ _GET ['']パラメータを持つカスタムテンプレートがあります。物事は私がそれを始めるために働くためにそれを必要とするだけです、今のように、私がしても何も起こりません。最も単純なadd_rewrite_ruleは何にも影響しません。 .htaccessがサイトのルートフォルダにあること、そして正しいfunctions.phpファイルを編集していることを確認します。

function custom_rewrite_basic() {
  add_rewrite_rule('^leaf/([0-9]+)/?', 'index.php?page_id=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');

.htaccessファイル(これは完全に生成されていますが、私の関数のトラックは書き換えられていません)。

# BEGIN WpFastestCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_Host} ^www.mywebsite.com [NC]
RewriteRule ^(.*)$ http\:\/\/mywebsite\.com\/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit)
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /storage/content/64/117764/mywebsite.com/public_html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch "\.(?i:ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|x-html|css|xml|js|woff|woff2|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=2592000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache

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

# END WordPress

# BEGIN mywebsite
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>

#ENDjapgoi
2
mpj

他の誰かが示唆したように、私は私のテーマを再起動しました、そしてそれは働き始めました!

2
mpj