Title: Exclude from wordpress rewrite rules
Last modified: August 7, 2017

---

# Exclude from wordpress rewrite rules

 *  [garrettlynch](https://wordpress.org/support/users/garrettlynch/)
 * (@garrettlynch)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/exclude-from-wordpress-rewrite-rules/)
 * Attempting to exclude a folder ‘test’ from the wordpress rewrite rules in the
   htaccess file and give it a unique rewrite. Test isn’t a real folder.
 * 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
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/exclude-from-wordpress-rewrite-rules/#post-9388162)
 * The following will probably work:
 *     ```
       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.
 *  Thread Starter [garrettlynch](https://wordpress.org/support/users/garrettlynch/)
 * (@garrettlynch)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/exclude-from-wordpress-rewrite-rules/#post-9388339)
 * Thanks but nope neither works. I had already tested with something similar:
 * `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/`.
 *  Thread Starter [garrettlynch](https://wordpress.org/support/users/garrettlynch/)
 * (@garrettlynch)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/exclude-from-wordpress-rewrite-rules/#post-9388756)
 * I was wondering if the rewrite to index.php was causing a particular issue. So
   I made a dummy test.php page and tried this:
 *     ```
       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.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude from wordpress rewrite rules’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)
 * [mod-rewrite](https://wordpress.org/support/topic-tag/mod-rewrite/)
 * [rewriterule](https://wordpress.org/support/topic-tag/rewriterule/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [garrettlynch](https://wordpress.org/support/users/garrettlynch/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/exclude-from-wordpress-rewrite-rules/#post-9388756)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
