由于某种原因,我的网页没有重定向。我正在尝试在我的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
RewriteEngine On
Options +FollowSymLinks
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+)\.html$ /$1-$2-in-$3.html
# 301 --- http://www.domain.com/music-classes-san-diego-ca.html => http://www.domain.com/music-classes-in-san-diego-ca.html
RewriteRule ^music-classes-san-diego-ca\.html$ /music-classes-in-san-diego-ca.html? [L,R=301]
301重定向是我正在努力工作的。这不是为我重定向。我也试过这个:
redirect 301 music-classes-san-diego-ca.html http://www.domain.com/music-classes-in-san-diego-ca.html
答案 0 :(得分:1)
任何时候你使用wordpress,这些规则总是需要最后,因为它将一切都路由到index.php。在wordpress规则之前尝试你的规则。仅供参考,我个人会使用Rewrite来获取所有301,而不是将它们与RedirectMatch
混合使用。
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^music-classes-san-diego-ca\.html$ /music-classes-in-san-diego-ca.html? [L,R=301]
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+)\.html$ /$1-$2-in-$3.html
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress