0

I have 5 wordpress sites that all use the same encoded template. That encoded template (which I can't change) calls on a file called "2012.orange.html" with some basic html layout code. I have created a "my_template.php" in my server's "/home/" directory and another "2012_orange.php" file in my template directory that "includes" "my_template.php" from the "/home/".

My goal is for my "my_template.php" file in the "/home/" directory to be used to control the layout of the 5 different sites, but I can't figure out how to get the specific .html file to call the .php instead.

I did something similar with my 'robots.txt' using the following code, and it works well:

# BEGIN - Robots Rewrite
RewriteEngine on
RewriteRule ^robots\.txt$ robots.php [L]
## END - Robots Rewrite

But I can't get this to work...I am getting no html layout:

# BEGIN - Template Rewrite
RewriteEngine on
RewriteRule ^2012\.orange\.html$ 2012_orange.php [L]
## END - Template Rewrite

And then again, the 2012_orange.php would just contain the following include:

<?php include ('/home/my_template.php'); ?>

Any idea on how to get .htaccess to redirect to the .php version of the file when the original .html is called?

2 Answers 2

1

.htaccess is only used in the HTTP request to redirect an url. Once the script is running, including templates is not incluenced in any way by .htaccess, since you're including files, not urls.

Sign up to request clarification or add additional context in comments.

Comments

1

can you type 2012_orange.php file path from the public folder?

Your code seems working fine for 2012_orange.php in the root directory,

if you having 2012_orange.php file inside another folder you have to change path like home/2012_orange.php

# BEGIN - Template Rewrite
RewriteEngine on
RewriteRule ^2012\.orange\.html$ home/2012_orange.php [L]
## END - Template Rewrite

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.