Redirect URL with mod_rewrite with variable

I am looking to get a rule setup to change one of my URL’s. After much research I understand the basics of mod_rewrite. The trouble I am having is the dynamic URL that is being re written. I have outlined in as much detail possible the task and desired outcome.

I currently have a url that looks like this:

Read More
http://www.myndness.com/my-canvas/{username}/

The {Username} is variable depending on which user you click on.

What I need to do is add /?my_posts to the end of that URL. This will then display the posts module by default for all users.

So all the users will follow the same URL pattern:

/User1/?my_posts
/User2/?my_posts
/User3/?my_posts
/User4/?my_posts

Apologies if I have missed anything.

I am using WordPress and have access to all files on the server.

Related posts

1 comment

  1. Try this:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^my-canvas/[^/]+/?$ $0?my_posts [R=301,L,NC]
    

Comments are closed.