• I recently moved the contents of a custom webapp into WordPress, the permalinks and such are working great with the stock htaccess file below:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    However, in my application, I had links such as:

    custom.php?link=20061031

    Now, I tried adding:

    RewriteRule ^custom\.php\?link=20061031$ /2007/01/old-2006-10-31-entry

    /2007/01/old-2006-10-31-entry exists, and works if I access it directly. However, depending on where I put this rewrite rule, I either end up with WP’s 404 or I end up with Internal Server errors which the error log suggests an endless redirect.

    So, given that custom.php obviously doesnt exist anymore, how do I write this rule and where would I place it in the above htaccess?

    Thanks in advance for any advice.

Viewing 1 replies (of 1 total)
  • Thread Starter ijk

    (@ijk)

    Just to follow up, I’ve found some of the answers here
    https://iamtgc.com/2007/06/02/definitive-guide-to-wordpress-rewrites/

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    # Custom rules need to go here
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    And for urls such as the above custom.php?link=20061031 need rewrite rules like this

    RewriteCond %{query_string} ^link=20061031$
    RewriteRule ^custom\.php$ /2007/10/31/entry-name? [R=301,L]

Viewing 1 replies (of 1 total)
  • The topic ‘Where do I write Custom Rewrite rules?’ is closed to new replies.