2016-09-14 9 views
1

私はWordPress内の.htaccessファイルに2つの301リダイレクトを適用しようとしていますが、404エラーが発生します。ここで301リダイレクトはWordPress内の.htaccess経由では動作しません

は、私が持っているものです。

# 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 

# X-XSS-Protection 
<IfModule mod_headers.c> 
    Header set X-XSS-Protection "1; mode=block" 
</IfModule> 

# X-Frame-Options 
<IfModule mod_headers.c> 
    Header always append X-Frame-Options SAMEORIGIN 
</IfModule> 

# Security Headers - X-Content-Type: nosniff 
<IfModule mod_headers.c> 
    Header set X-Content-Type-Options nosniff 
</IfModule> 

# BEGIN 301 Redirects 
Redirect 301 /old-page-name/ https://www.myurl.com/new-page-name/ 
Redirect 301 /another-old-page/ https://www.myurl.com/another-new-page/ 
# END 301 Redirects 

私はここで間違って何をしているのですか?私はまた、WordPress設定の上にリダイレクト情報を置こうとしました。

+1

試してみてください: 'のRewriteRule ^古いページ名/ https://www.myurl.com/new-page-name/ [L、R = 301]

は、このようなあなたのルールを持っています'below' RewriteBase/'line – anubhava

答えて

4

mod_rewriteの規則の順序は、mod_aliasRedirectディレクティブ)の規則の混在が発生します。

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteRule ^old-page-name(/.*)?$ https://www.myurl.com/new-page-name/ [L,R=301,NC] 

RewriteRule ^another-old-page(/.*)?$ https://www.myurl.com/another-new-page/ [L,R=301,NC] 

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

これはうまくいきません。私はpermalinksをフラッシュし、キャッシュをクリアしようとしました。まだ404を取得しています。 – Squideyes

+0

上記のコードに従ってhttps://www.myurl.com/old-page-name/ – Squideyes

+0

また、パーマリンクをワードプレスでリセットすると、追加した変更がクリアされることがわかりました。 – Squideyes

関連する問題