homepage Welcome to WebmasterWorld Guest from 174.129.163.183
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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
JeremyL




msg:3799596
 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?

 

JeremyL




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

NM, just added this to the beginning

RewriteCond %{REQUEST_FILENAME} !-f

jdMorgan




msg:3799641
 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... :)

Jim

g1smd




msg:3799647
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved