.htaccess:RewriteRule:坏标记分隔符

时间:2014-12-05 19:29:54

标签: wordpress .htaccess mod-rewrite

把头发拉过这一头。我有以下.htaccess文件,除了Wordpress的默认设置外,还会执行一些自定义重定向。在我的本地Wamp服务器上进行测试时,它工作正常,但在转移到生产后,我在服务器日志中没有出现RewriteRule: bad flag delimiters错误,过了一段时间后网站甚至出现了internal server error

任何帮助将不胜感激。提前谢谢!

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^rockford_weddings___welcome\.html$ /wedding/ [R=301,L]
RewriteRule ^blog/?$ /journal/ [R=301,L]
RewriteRule ^blog/(.*)$ /$1 [R=301,L]

RewriteRule ^portraitinvestment/?$ /portraitinvestment\.pdf [R=301,L]
RewriteRule ^weddinginvestment/?$ /weddinginvestment\.pdf [R=301,L]
RewriteRule ^holidaycards2014/?$ /holidaycards2014\.pdf [R=301,L]
</IfModule>

# 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

1 个答案:

答案 0 :(得分:1)

可能是换行错误或某些字符集。

试试这个:

  1. 将您的自定义htaccess内容复制粘贴到某处:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^rockford_weddings___welcome\.html$ /wedding/ [R=301,L]
    RewriteRule ^blog/?$ /journal/ [R=301,L]
    RewriteRule ^blog/(.*)$ /$1 [R=301,L]
    
    RewriteRule ^portraitinvestment/?$ /portraitinvestment\.pdf [R=301,L]
    RewriteRule ^weddinginvestment/?$ /weddinginvestment\.pdf [R=301,L]
    RewriteRule ^holidaycards2014/?$ /holidaycards2014\.pdf [R=301,L]
    </IfModule>
    
  2. 从服务器

  3. 删除.htaccess文件
  4. 转到wordpress管理面板,找到选项 - &gt;固定链接
  5. 保存。 (它将重新生成.htaccess文件)
  6. 测试公共网站是否有效
  7. 复制粘贴htaccess文件的自定义代码开头