Title: mod-rewrite error
Last modified: August 19, 2016

---

# mod-rewrite error

 *  Resolved [thaking](https://wordpress.org/support/users/thaking/)
 * (@thaking)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/)
 * using fGallery and long ago i had used the mod-rewrite option for my photos (
   don’t remember why i had to use it, just did) and i put “photos” in the mod-rewrite
   box and clicked “update mod-rewrite”..tonight, i removed the word “photos” and
   clicked the button again…now i cannot get to my site…how do i fix this?
 * i really hope someone can assist…

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

 *  Thread Starter [thaking](https://wordpress.org/support/users/thaking/)
 * (@thaking)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/#post-823738)
 * looking at the database, in the options table, there is an option for “page” 
   and an option for “baseurl”…these specifically relate to fGallery…would one of
   those have affected it? i assumed since i can’t get to the site at all, that 
   it wouldn’t have to do with the options of fGallery, but wordpress…
 *  Thread Starter [thaking](https://wordpress.org/support/users/thaking/)
 * (@thaking)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/#post-823870)
 * ok, here’s what i’ve found in the code for the gallery….hopefully someone can
   help figure out what i need to do:
 *     ```
       function fim_rewrite_rule()
       {
           // Complete url
           $url = get_bloginfo('wpurl');
           $urlparts = parse_url($url);
       	$base = get_option('fim_baseurl');
       	$rewrite = "# BEGIN FGALLERY\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteRule ^$base/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$   $urlparts[path]/wp-content/plugins/fgallery/fim_photos.php?$1=$2&$3=$4 [QSA,L]\n</IfModule>\n# END FGALLERY\n";
   
       	return $rewrite;
       }
       if(isset($_POST['rewrite']))
       {
       	$url = $_POST['baseurl'];
       	$url = strtolower($url);
       	$url = str_replace(" ", "_", $url);
       	update_option('fim_baseurl', $url);
       	$file = "../.htaccess";
   
       	if(is_writable($file))
       	{
       		$content = file_get_contents ($file);
       		$content = preg_replace("/(# BEGIN FGALLERY)(\n+.*)*(# END FGALLERY)\n/", "", $content);
   
       		$content = fim_rewrite_rule().$content;
       		$f = fopen("../.htaccess", "w");
       		fwrite($f, $content);
       		fclose($f);
       		//echo "<pre>$content</pre>";
       		echo "<div class='updated fade' id='message'><p>".__('Mod ReWrite rules successfully updated', 'fgallery').".</p></div>";
   
       	}
       	else
       	{
       		?><div class="wrap">
       		<h2><?php _e("Add ReWrite rules", 'fgallery');?></h2>
       		<?php _e(".htaccess is not writable so you have to add add the following manually", 'fgallery');
       		echo "<p>".__('This should be at the TOP of your .htacces file before the WordPress rules', 'fgallery').".</p>";?>
       		<textarea cols="100" rows="5" wrap="off"><?php echo fim_rewrite_rule(); ?></textarea></div><?php
       	}
   
       }
       ```
   
 * do i need to look at my htaccess file and correct something there?
 *  Thread Starter [thaking](https://wordpress.org/support/users/thaking/)
 * (@thaking)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/#post-823878)
 * here’s my htaccess file:
 *     ```
       # BEGIN FGALLERY
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteRule ^/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$   /wp-content/plugins/fgallery/fim_photos.php?$1=$2&$3=$4 [QSA,L]
       </IfModule>
       # END FGALLERY
       # BEGIN FGALLERY
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteRule ^photos/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$   /wp-content/plugins/fgallery/fim_photos.php?$1=$2&$3=$4 [QSA,L]
       </IfModule>
       # END FGALLERY
       # BEGIN WordPress
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       </IfModule>
   
       # END WordPress
       ```
   
 *  Thread Starter [thaking](https://wordpress.org/support/users/thaking/)
 * (@thaking)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/#post-823932)
 * no one knows anything about mod-rewrites?

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

The topic ‘mod-rewrite error’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 1 participant
 * Last reply from: [thaking](https://wordpress.org/support/users/thaking/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/mod-rewrite-error/#post-823932)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
