Title: Mod Rewrite Problems&#8230;
Last modified: August 18, 2016

---

# Mod Rewrite Problems…

 *  [Shaney](https://wordpress.org/support/users/shaney/)
 * (@shaney)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/)
 * Hello,
 * I have modified my WordPress theme so that I can use query strings to insert 
   static content from files onto my WordPress blog using the PHP include(); function.
 * For example, [http://domain.com/index.php?content=contact](http://domain.com/index.php?content=contact)
   would insert the the contents of the file called contact.php into the sidebar
   of my wordpress blog.
 * I am trying to use mod-rewrite to tidy up my URLs, so that [http://domain.com/content/contact/](http://domain.com/content/contact/)
   will redirect to [http://domain.com/index.php?content=contact](http://domain.com/index.php?content=contact)
 * I have enabled permalinks on WordPress and this is the code that is presently
   in my .htaaccess file:
 * `<IfModule mod_rewrite.c>
    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}!-
   f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule
   >
 * In order to make my non-wordpress mod-rewrite function to work, I have pasted
   the mod-rewrite code needed above the wordpress generated code:
 * `RewriteEngine On
    RewriteRule ^content/([^/]*)/$ /index.php?content=$1 [L]
 * `<IfModule mod_rewrite.c>
    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}!-
   f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule
   >
 * **However**, this does not seem to work. When I navigate to the URL: [http://domain.com/content/contact/](http://domain.com/content/contact/),
   instead of seeing my contact data included on the page, I see the 404 error file
   that is apart of my wordpress theme.
 * For some unknown reason, it looks as if I cannot get my mod-rewrite function 
   and the wordpress mod-rewrite function to work together.
 * I would be grateful if anyone could tell me if I an doing anything wrong – and
   if so, is there any way I could fix things ?
 * Thank you all in advance 🙂
 * EDIT:
    Wordpress: version 2.0.1 Apache: 1.3.33 PHP: 4.3.11
 * I am not running any WordPress plugins, apart from Askimet.

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

 *  [geoffe](https://wordpress.org/support/users/geoffe/)
 * (@geoffe)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337021)
 * I don’t understand if or why you are putting your rule ahead of the others in
   the htaccess file.
 * And what code do you have in the WordPress index.php to call the contact.php 
   file?
 * Or is this code in sidebar.php as I would expect if this is going into the sidebar?
 * And what’s the point of using a rewrite rule to pass a variable that is only 
   used to include a file? The user won’t see the URI anyway. Are you using permalinks
   just to code that in?
 *  [geoffe](https://wordpress.org/support/users/geoffe/)
 * (@geoffe)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337022)
 * ok i see you updated to turn the Rewrite engine on twice. If you are adding your
   own rules, you should use this:
    <IfModule mod_rewrite.c> RewriteEngine On RewriteBase/
   RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule./
   index.php [L]
 * RewriteRule ^content/([^/]*)/$ /index.php?content=$1 [L]
    </IfModule>
 *  [Direkt](https://wordpress.org/support/users/direkt/)
 * (@direkt)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337024)
 * Also, don’t bother rewriting the rules, since by default, you can do `http://
   url/content/contact` and have it work
 *  [zeddy](https://wordpress.org/support/users/zeddy/)
 * (@zeddy)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337025)
 * Hi,
 * I’m newbie. Could you explain me some moments. Where should i place .htaccess
   file and what is it – </IfModule>. Should i change something in templates?
 * I want to make direct links without “?”. Such links better for search engines.
 *  Thread Starter [Shaney](https://wordpress.org/support/users/shaney/)
 * (@shaney)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337026)
 * Inside my sidebar.php file I have:
 * `<?php 
    $path = "./"; $ext = ".php";
 *  if (preg_match("#^[a-z0-9_-]+$#i", $_GET["page"]) && file_exists($path . $_GET["
   page"] . $ext)) {
    $filename = $path . $_GET["page"] . $ext; include($filename);}
 * else {
 *  include("ORIGINAL_SIDEBAR_FILE.php");}
 * ?>
 * “And what’s the point of using a rewrite rule to pass a variable that is only
   used to include a file? The user won’t see the URI anyway. Are you using permalinks
   just to code that in?”
 * The point is that so users can see my wordpress blog with a contact form on the
   right of the page if they type: mydomain.com/content/contact/
 * Or if they type mydomain.com/content/chat/ my wordpress blog will be displayed,
   with a java chat applet on the right side of the page.
 * I have pasted the code you have posted – thank you. However, the same problem
   still remains.
 *  Thread Starter [Shaney](https://wordpress.org/support/users/shaney/)
 * (@shaney)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337028)
 * “Also, don’t bother rewriting the rules, since by default, you can do [http://url/content/contact](http://url/content/contact)
   and have it work”
 * This does not work when permalinks are enabled in wordpress. Which is the problem
   I’m trying to solve. It looks as if user created mod rewrite rules are ignored
   when the wordpress permalinks/rules are turned on.
 *  [Direkt](https://wordpress.org/support/users/direkt/)
 * (@direkt)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337029)
 * It does work, for instance, look at my example:
    [http://liquidity.dnsalias.net/static/click](http://liquidity.dnsalias.net/static/click)
 * And the rest of the site is permalink enabled, but I’m using the EzStatic plugin,
   so thats why it may work for me.
 *  Thread Starter [Shaney](https://wordpress.org/support/users/shaney/)
 * (@shaney)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337036)
 * I shall try the EzStatic plugin later.
 * After some Googling, it seems as if I’m not the only one with this issue: [http://wordpress.org/support/topic/57249?replies=6](http://wordpress.org/support/topic/57249?replies=6)
 *  [geoffe](https://wordpress.org/support/users/geoffe/)
 * (@geoffe)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337041)
 * I’m not sure where to begin on your sidebar.php code.
 * I believe what you’re doing is requesting from [http://domain.com/content/contact/](http://domain.com/content/contact/)
   a file that reads ‘./contact.php’ which means it’s looking for ‘[http://domain.com/content/contact/contact.php&#8217](http://domain.com/content/contact/contact.php&#8217);
   Try ‘/contact.php’ which should bring ‘[http://domain.com/contact.php&#8217](http://domain.com/contact.php&#8217);
   although this wouldn’t explain your 404 error.
 * This whole method still seems bizarre to me. You could just create a static page
   for contact.php and write in a condition for sidebar.php to say that if this 
   is the contact page, include this contact form code. See here: [http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page](http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page)
 * What is the content of the main area if you have a contact page with contact 
   content only in the sidebar?

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

The topic ‘Mod Rewrite Problems…’ is closed to new replies.

## Tags

 * [modrewrite](https://wordpress.org/support/topic-tag/modrewrite/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 4 participants
 * Last reply from: [geoffe](https://wordpress.org/support/users/geoffe/)
 * Last activity: [20 years, 1 month ago](https://wordpress.org/support/topic/mod-rewrite-problems/#post-337041)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
