homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Rewrite Extension But Exlude Certain Directories

 1:00 am on Dec 4, 2008 (gmt 0)

So I'm converting a site to WordPress and keeping the URLs for the content the same except removing the .php extension. My htaccess looks like this

#RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
#RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.domain.com/$1 [R=301,L]

The problem is the script is trying to remove the extension from even the WordPress scripts. How do I make it so the 3 default WordPress folders and the handful of WordPress scripts in the root are not rewritten?



 1:14 am on Dec 4, 2008 (gmt 0)

NM, just added this to the beginning

RewriteCond %{REQUEST_FILENAME} !-f


 2:08 am on Dec 4, 2008 (gmt 0)

I suspect you also removed the "#" symbols from those lines: Otherwise, they are just treated as comments...

If possible, use a specific exclusion pattern based on the WP script names or on the common directory path to those scripts, rather than checking the disk for "file exists" for each and every .php file requested from your server. The fewer file-exists and directory-exists checks you do, the longer it will be before your successful site has to be moved to a dedicated server... :)



 2:12 am on Dec 4, 2008 (gmt 0)

Use more RewriteCond lines to exclude those folders from applying.

A ! means NOT, here.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved