views:

31

answers:

2

Hi! I just wanted to know if there is someway to use the htaccess file to chnage the content of a page(s). Maybe something sort of like the redirect, but instead of sending the user to another page, it would just change the content of the whole page.

Thank you for any and all help!

+1  A: 

Sure, mod_rewrite will serve up another page in the place of the requested without changing the url. There are many questions here covering the topic of mod_rewrite that you can browse.

Example:

RewriteEngine on
RewriteRule ^page1.html$ page2.html

This will serve the content of page2.html when page1.html is requested while leaving the addressbar reading http://somesite.com/page1.html.

Jonathan Sampson
But is there a way to physically change the content of the page? The problem is, I dont need just page1 to redirect to page0 and show page1, I am also going to need page2 to redirect to page0 and show page2, and page3 to redirect to page0, and show page3
Sean
I'm sorry, Sean, but your request isn't clear.
Jonathan Sampson
A: 

You might want to try something like this:

RewriteEngine on
RewriteRule * handler.php

Where handler.php conatins the logic to decide which page should be loaded based on the HTTP_REFER parameter. That is, unless you have some reason for not doing an approach like this

AndrewMurphy