Search code examples
wordpress.htaccessurl-rewritingpermalinks

Additional .htaccess Rewrite Condition with Wordpress


I wish to remove part of a pluggin's URL in Wordpress. I have a standard permalinks setup but have three URLSs with a similar iffy prefix I wish to clean up:

Currently I have

http://domain.com/?pfwk_cats=works

And I require:

http://domain.com/portfolio-works

My current htaccess looks like:

# 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

My solution was to add:

RewriteEngine On
RewriteRule ^portfolio-([^/]*)$ /?pfwk_cats=$1 [L]

But it does not kick in? Any ideas? I assuming the Wordpress Rewrite rules are messing it up? Help much appreciated!


Solution

  • You need to make sure your custom rule is above the #BEGIN WordPress line. The WordPress rewrite rule is a "catch all" so if you put yours below, it will never get there.

    Also, don't forget to restart Apache: service httpd graceful

    ~tommy