Title: Apache Mod_Rewrite not being applied correctly
Last modified: January 31, 2020

---

# Apache Mod_Rewrite not being applied correctly

 *  [shspivey](https://wordpress.org/support/users/shspivey/)
 * (@shspivey)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/apache-mod_rewrite-not-being-applied-correctly/)
 * I am trying to get a rewrite rule to work on a Multisite setup but with no luck.
   Here is what I need the rule to do:
 * [http://county.asystyoutech.net/business-directory/25/administration/](http://county.asystyoutech.net/business-directory/25/administration/)
 * to this:
 * [http://county.asystyoutech.net/departments/administration/](http://county.asystyoutech.net/departments/administration/)
 * Here is my RewriteCond and RewriteRule:
 * RewriteCond %{HTTP_HOST} website.com
    RewriteRule ^business-directory/.*?/(.*?)(/.
   +?)?$ /departments/$1$2
 * I have the rule added to httpd-app.conf
 * I am logging the rewrite_mod output to my error_log in apache. I am monitoring
   the log file as I hit URLs on my site that need re-writing. I can see where the
   pattern from my rule is applied but nothing else happens after the application.
   Here is an excerpt from the log file.
 * > applying pattern ‘^business-directory/.?/(.?)(/.+?)?$’ to uri ‘wp-content/plugins/
   > business-directory-plugin/assets/css/dnd-upload.min.css’, referer: [http://county.asystyoutech.net/business-directory/54/building-inspector/](http://county.asystyoutech.net/business-directory/54/building-inspector/)
   > 
   > pass through /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/business-
   > directory-plugin/assets/css/dnd-upload.min.css, referer: [http://county.asystyoutech.net/business-directory/54/building-inspector/](http://county.asystyoutech.net/business-directory/54/building-inspector/)
   > strip per-dir prefix: /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/
   > business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css -> wp-content/
   > plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css,
   > referer: [http://county.asystyoutech.net/business-directory/54/building-inspector/](http://county.asystyoutech.net/business-directory/54/building-inspector/)
   > applying pattern ‘^index\.php$’ to uri ‘wp-content/plugins/business-directory-
   > plugin/vendors/select2-4.0.5/css/select2.min.css’, referer: [http://county.asystyoutech.net/business-directory/54/building-inspector/](http://county.asystyoutech.net/business-directory/54/building-inspector/)
   > strip per-dir prefix: /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/
   > business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css -> wp-content/
   > plugins/business-directory-plugin/vendors/select2-4.0.5/css/select2.min.css,
   > referer: [http://county.asystyoutech.net/business-directory/54/building-inspector/](http://county.asystyoutech.net/business-directory/54/building-inspector/)
 * I am testing the rewrite rule with this tool and the output is what I am expecting.
 * [https://htaccess.madewithlove.be?share=e001da82-cf80-54a6-a34a-e943f1519700](https://htaccess.madewithlove.be?share=e001da82-cf80-54a6-a34a-e943f1519700)
 * I have searched through everything I can find on this topic specific to apache
   and wordpress but haven’t found anything that gets me closer to a solution. Any
   suggestions on what might be wrong?
 * I have posted this to the Bitnami support forum and they directed me to post 
   here and see if someone on the WordPress forum could offer help.

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/apache-mod_rewrite-not-being-applied-correctly/#post-12387130)
 * That log snippet isn’t for a request matching the regexp, so it’s not helpful.
   Rules are applied to all requests. When there is not a match, it’s “passed through”
   to the next rule.
 * I think a problem with your regexp is the match all lazy modifier `.*?` isn’t
   doing what you expect. I suggest instead excluding the `/` from possible matches
   like so: `[^/]*`.
 * Thus `^business-directory/[^/]*/([^/]*)(/[^/]+)?$`
 * If the first element after business-directory/ is always numeric, consider `[
   0-9]*` or even `[0-9]{2}` if it’s always two digits.
 * While it’s not specific for .htaccess, you could use a tool like the one at regexr.
   com to test regexp expressions. There you could see how your regexp doesn’t work
   as expected.

Viewing 1 replies (of 1 total)

The topic ‘Apache Mod_Rewrite not being applied correctly’ is closed to new replies.

## Tags

 * [apache](https://wordpress.org/support/topic-tag/apache/)
 * [mod_rewrite](https://wordpress.org/support/topic-tag/mod_rewrite/)
 * [wordpress multisite](https://wordpress.org/support/topic-tag/wordpress-multisite/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/apache-mod_rewrite-not-being-applied-correctly/#post-12387130)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
