Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Building a site that we want the home page controlled by it (main page will be the main blog page as well as the site home); it should also control a couple other pages such as the contact us page and the about us page.

However, we don't want it to control any of the other pages. Seems easy enough, but problem is wouldn't wordpress' rewrite code in the .htaccess file take control of all pages in the root of the site?

We want to control the other pages ourselves via .htaccess and currently use this rewrite code in our .htaccess file..

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteRule ^browse/([0-9]+)/[a-zA-Z-]+/? browse.php?sport_id=$1
RewriteRule ^browse/([0-9]+)/([0-9]+)/[a-zA-Z0-9-]+/? browse.php?sport_id=$1&year_id=$2&type=set
RewriteRule ^set/([0-9]+)/[a-zA-Z-]+/[a-zA-Z0-9.-]+/([a-z_]+)/? set.php?set_id=$1&type=$2

However if we moved the site to WordPress how can we continue to make use of this without WordPress overriding it?

Additionally, even if we were able to overwrite it, I'm concerned about the code being wiped if WordPress regenerates it's .htaccess file for some reason.

Is it possible to do what we want to do? Only thing I can think of is storing WordPress in a sub-directory but then doing some rewrite code that rewrites people that go to certain pages such as the home page of the site to the sub-directory where WP is installed?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Any rewrite rules that appear before WordPress's own rules will get parsed first. You just need an L flag for your custom rules to stop processing if a request matches.

Then add the comments # BEGIN WordPress and # END WordPress where you want WordPress to add it's rules, after your own, and WordPress won't touch anything outside.

share|improve this answer
    
So I just add [L] to the end of my own rules? Only issue I still see is if WP decides to recreate the file (via changing of permalinks or a plugin perhaps) and wipe out what I have put in there. –  Brett Jun 27 '13 at 15:14
    
that's what the two begin and end comments are for, WordPress doesn't overwrite the whole file, it looks for the comments and only overwrites what's between them. –  Milo Jun 27 '13 at 15:16
    
Oh ok nice! So to clarify, I put my rules above the WP rules and then add a [L] flag to the end of each rule? –  Brett Jun 27 '13 at 15:22
    
yes, that's correct. –  Milo Jun 27 '13 at 15:24
    
Great - thanks! –  Brett Jun 27 '13 at 15:26
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.