htaccess ignores wordpress folders and directories

I have a wordpress site where when a person arrives at domain.com/variable I am using htaccess to rewrite the url to become domain.com/?ref=variable

This works fine except that when a page exists that also gets rewritten unless followed with a forward slash / so for example, I have a page called /members and if you went to

Read More

domain.com/members that would be rewritten to domain.com/?ref=members which is NOT what I want.

If you go to domain.com/members/ (with the forward slash at the end) then the rewrite does not happen which is what I do want to happen

Is there any way that I can stop the rewrite happening when a person goes to domain.com/members (without the forward slash?)

This is what I have…

RewriteEngine On
RewriteRule ^([0-9a-zA-Z-_]+)$ index.php/?ref=$1 [R,L]

# 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

Thanks in advance

Steve

Related posts

Leave a Reply