So this: /test/post1/
or this /test/post1
should rewrite to /index.php?pagename=$1
where $1 is the posttitle e.g. post1. I think I have the exclusion working as a RewriteCond (see below) – how do I add the RewriteRule for it?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(test|test/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
]]>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^/test/(\w+)/$ /index.php?pagename=$1 [L]
RewriteRule ^/test/(\w+) /index.php?pagename=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The first new rule is probably not necessary; you should check whether it works with only the second rule.
Note that for security reasons, the new rules limit the page names to only having letters, numbers, and underscores. You should make every effort to abide by this limitation, but if you cannot, then the rules must be changed accordingly. Also note that if you remove the limitation, you will definitely need two rules.
]]>RewriteRule ^/test/([^/]*)-([0-9]+)/$ index.php?pagename=$1 [L]
which doesn’t work either. Everything I’ve tried just does a redirect instead of a rewrite so for example /test/post1/
just changes in the browser address bar to /post1/
.
RewriteCond %{REQUEST_URI} ^/(test|test/.*)$
RewriteRule . /test.php?pagename=$1 [L]
That works but I couldn’t get this to work:
RewriteRule ^/(test|test/.*)$ /test.php?pagename=$1 [L]
Anyway I could duplicate the index.php page in test.php as a work around – I’d rather not, if anyone knows how to get it to work that would be greatly appreciated.
]]>