Wordpress missing blog permalink

后端 未结 1 897
傲寒
傲寒 2021-01-24 18:35

I set up my Wordpress website, imported all blog post and submitted my sitemap to Google last month.

I realized that my blog posts appear like: www.domain.com/blog-post-

1条回答
  •  终归单人心
    2021-01-24 18:40

    This should work for you (changing the www.domain.com to your domain) :

    Options -Indexes +SymLinksIfOwnerMatch
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{REQUEST_URI} !^/blog/
    
    # Don't apply to URLs that go to existing files or folders
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all those to insert /blog
    RewriteRule ^(.*)$ http://www.domain.com/blog/$1 [L,R=301]
    

    EDIT: This will rewrite specific urls:

    RewriteEngine On
    RewriteRule ^blog-post1$ http://www.example.com/blog/blog-post1 [R=301,L]
    RewriteRule ^blog-post2$ http://www.example.com/blog/blog-post2 [R=301,L]
    

    0 讨论(0)
提交回复
热议问题