0

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?

2

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.

  • 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
  • Can I ask what about other pages or directories that you don't want wordpress to control? Such as if I had a file called test.php or a directory called 'my-dir'? Will WP try and control those? – Brett Jul 7 '13 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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