• Resolved ahirai

    (@ahirai)


    Suppose I have a blog article at:
    https://www.example.com/blog/2009/02/my-article/

    I have a newsletter. The newsletter software adds tracking parameters to the URLs embedded in the newsletter. So, if I try to link to the article referenced above, the newsletter software ends up sending a link to something like:
    https://www.example.com/blog/2009/02/my-article/?w=el&x=302692&y=3&z=952a7ad62d

    When a newsletter recipient clicks on the link, WordPress returns an error stating “Sorry, but you are looking for something that isn’t here.”

    Question: How do I get WP to display the correct page?

    I’ve tried adding variations on the following line to my .htaccess file, but without any success:

    RewriteRule ^https://www.example.com/blog/2009/02/my-article/.+$ https://www.example.com/blog/2009/02/my-article/

    [Note: I’ve tried doing this in the .htaccess files in both the root directory (example.com/) and in the blog directory (example.com/blog)]

    Please help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ahirai

    (@ahirai)

    Note: I’ve also tried the following rule:

    RewriteRule ^/blog/([0-9]{4})/([0-9]{2})/([a-z-]+)/(\?[=\&a-z0-9/\.:-]+)$ /blog/$1/$2/$3/ [R]

    This doesn’t seem to do the trick either. I suspect the problem might have to do with the order in which rules appear in the .htaccess file. Maybe the rule I’m trying to enter is being overridden by something else.

    The .htaccess file in my /blog directory contains the following:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    RewriteRule ^/blog/([0-9]{4})/([0-9]{2})/([a-z-]+)/(\?[=\&a-z0-9/\.:-]+)$ /blog/$1/$2/$3/ [R]
    </IfModule>
    # END WordPress

    Please advise…

    I don’t know about your code or issues in particular, but in general, you should keep your own added code outside of the WordPress section.

    Try the following in your /blog/ subdirectory .htaccess:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/blog/([0-9]{4})/([0-9]{2})/([a-z0-9-]+)/
    RewriteRule ^(.*) /$1? [R]
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress

    The end result is your same query line, without the querystring (? and beyond).

    Thread Starter ahirai

    (@ahirai)

    It works!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Mod Rewrite question’ is closed to new replies.