Is there someway to change the content of a page with the htaccess file?
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.
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
.
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
Check out mod_ext_filter Apache Module http://httpd.apache.org/docs/2.2/mod/mod_ext_filter.html
Using sed to replace text in the response
# mod_ext_filter directive to define a filter which
# replaces text in the response
#
ExtFilterDefine fixtext mode=output intype=text/html \
cmd="/bin/sed s/verdana/arial/g"
<Location />
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext
</Location>
精彩评论