I’ve added some extra functionality to my wordpress so that I can visit it with a variable and do extra stuff.
The problem is, when I turn my ugly dynamic link into lovely permlink formatting in the .htaccess file, wordpress overrides it / ignores it. I’ve heard there’s a way to do it, but the ways I try to do it based off what people have said still returns a 404 page regardless. I know that the file its pointing to works.
2 ways ppl say works but I’ve had no joy with:
1) insert the rules above the #BEGIN wordpress part
2) use add_rewrite_rule() wordpress function somewhere
Has anybody had any success with these methods? or other methods?
Here’s what my .htaccess file looks like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/ref/(.*)$ /index.php?ref=1&sid=$1 [NC]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
In my themes function.php I’ve also tried adding:
add_rewrite_rule('/ref/(.*)$', 'index.php?ref=1&sid=$matches[1]','top');
With no success.
I’ve also tried the solutions over @ WordPress + mod_rewrite with no joy.
Please help! 🙂
any ideas?
This works – I just tested it – Note I added an L to the end of the RewriteRule
a new rule will always override the old ones
try the following
In .htaccess files you have to leave the leading slash in the patterns of the
RewriteRule
directive away. So try this:I wound up doing the following in php since the above solutions seemed to not work. WordPress rulership over the .htaccess file is supreme:
And from that have been able to do fairly much the same stuff. A pretty url that translates into something else.