• Resolved Sascha

    (@saschaehgmailcom)


    Hi there,

    I would like the post post_type (https://www.instrumentrentalbarcelona.com/?post_type=post) to display if someone goes to https://www.instrumentrentalbarcelona.com/blog. I have created rewrite in .htaccess and it is redirecting to /blog however it is giving me a 404.

    This is it including the rest of my rewrites:

    #Single URL Rewrite
    RewriteCond %{QUERY_STRING} ^post_type=post$
    RewriteRule ^$ /blog [QSD,R,L]
    
    #http www rewrite
    RewriteCond %{HTTP_HOST} ^instrumentrentalbarcelona.com [NC]
    RewriteRule ^(.*)$ https://www.instrumentrentalbarcelona.com/$1 [L,R=301,NC]
    
    # 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

    This is what you see when you go to the post post_type: https://www.screencast.com/t/ofJlpsGN6fNb (currently redirects to /blog and shows 404)

    Probably something real simple. Any advice would be greatly appreciated?

    Best,
    Sascha

    • This topic was modified 6 years, 4 months ago by Sascha.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your rewrite rules should be inside the if statement

    <IfModule mod_rewrite.c>
    here
    </IfModule>

    Thread Starter Sascha

    (@saschaehgmailcom)

    Thanks but unfortunately not. – that does not work and also they say you should not put anything inside the WordPress re-writes.

    Thread Starter Sascha

    (@saschaehgmailcom)

    Solution:
    > I wanted to show a page with all my blog posts.
    > This can be done if you use the WordPress post type “Post”. wpdomain.com/?post_type=post
    > I wanted that page to show when you go to wpdomain.com/blog
    >The following Rewrite works to show the desired URL:

    RewriteCond %{QUERY_STRING} ^post_type=post$ 
    RewriteRule ^$ /blog [QSD,R,L]

    > But /blog was giving a 404. So;
    > Create a page in WordPress called “blog”
    > Go to: Setting > Reading >Your homepage displays >Posts page: [Select page “blog”]
    Save and done.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Single URL mod_rewrite not showing post-type content’ is closed to new replies.