views:

46

answers:

3

I have an existing page of /programs/kids.php that I want to load a category page from WP. I want the .htaccess file in /programs to handle this rewriting for me.

Something along the lines of:

RewriteEngine on
ReWrite kids2.php http://www.mysite.com/blog/cat/kids/

Any help would be awesome.

+1  A: 

If your sure mod_rewrite is enabled by apache, the it is simple as

RewriteEngine on
RewriteRule kids.php http://www.mysite.com/blog/cat/kids/

or

RewriteEngine on
RewriteRule ^programs/kids.php$ http://www.mysite.com/blog/cat/kids/

depending on location and strictness (^hhh$ matches the whole string)

Eddie
This first one works, however, the browser is now displaying the blog url, rather than the original URL. Is there a flag or something to keep the original URL displayed?
Cory Dee
Sure, I think you just add [P] after the rule (with a space between)RewriteEngine onRewriteRule ^programs/kids.php$ http://www.mysite.com/blog/cat/kids/ [P]http://httpd.apache.org/docs/2.2/rewrite/rewrite_flags.html#flag_p
Eddie
Worked like a charm. Thanks!
Cory Dee
A: 

The directive is named RewriteRule and not just Rewrite. So try this:

RewriteRule ^programs/kids2\.php$ /blog/cat/kids/

But if you want have requests to /blog/cat/kids/ rewritten internally to /programs/kids2.php (the exact opposite of what you’ve mentioned), try this rule:

RewriteRule ^blog/cat/kids/$ programs/kids.php [L]
Gumbo
A: 

You could also do an include for that kids.php in the content of an existing WP page, but you'd need the ExecPHP plugin installed. Then kids.php would display as styled content inside a WordPress page. Which is sometimes desirable, from a site cohesiveness standpoint.

Something like this:

<?php require_once(ABSPATH. '/programs/kids.php');?>

Not exactly what you asked for, but maybe an alternative approach.

NDP