Welcome to WebmasterWorld Guest from 54.162.10.132

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite Extension But Exlude Certain Directories

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

Preferred Member

10+ Year Member

joined:Nov 22, 2000
posts: 487
votes: 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)

Preferred Member

10+ Year Member

joined:Nov 22, 2000
posts:487
votes: 0


NM, just added this to the beginning

RewriteCond %{REQUEST_FILENAME} !-f

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 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

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

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Use more RewriteCond lines to exclude those folders from applying.

A ! means NOT, here.