Display a certain page as the homepage

Permalink
I wasn't too sure whether or not to post it on the concrete5 forums, but is in some way related to concrete5 and everyone has been very helpful with my other questions so I figured why not.

I want my homepage (http://www.homepage.com ) to display a different page without changing the url. The reason why I can't simply make this other page the homepage is because this other page redirects to it's newest subpage and doing so changes the url. I would like for this "newest subpage" to display on my homepage url. How can this possibly be done. As always and help at all even a direction in which to look is really appreciated.

 
Alexmclovin replied on at Permalink Reply
I've done more research and have ended up using iframe. Could this lead to problems? It's working just as I want it at the moment. The code looks like:

<html>
<body style="margin:0px;padding:0px;overflow:hidden">
    <iframe src="#" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>
</body>
</html>
JohntheFish replied on at Permalink Reply
JohntheFish
This will likely affect your search engine position. But maybe that is not important to you.

Another way of achieving what you want is to map the home page url to whatever you want to display in an .htaccess file. You will have to be careful not to mess up the C5 rules in the .htaccess.
Alexmclovin replied on at Permalink Reply
Thanks for the response.

How would it effect my search engine position, and how badly?

And how would I go about mapping it in .htaccess?
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
Search engines do not index frames within pages so your home page could be indexed as if it has no content, but they do follow the link so the iframe could be indexed in its own right.

For your .htaccess file, you need to read up on mod_rewrite. A google search for htacess rewrite will yield lots of tutorials. The rewrite rules and conditions use regular expressions, so you will also want to read up on regular expressions.

Rules to rewrite just one page are along the lines of:
RewriteRule ^from/page.php$ to/page.php


The deatils depend on exactly what you want to rewrite and whether you want it just rewritten or redirected. Unfortunately its complicated stuff and a lot depends on your specific host environment, so while I have given some ideas below, there is no guarantee that these are right for you and will not break your server.

The added complication is that you are starting with the site index page, which depending on your server and preferences could be any of:
{empty path}
/
index.php
/index.php
/index.html
(and a few more)

One possibility is to put your new rewrite rules before the C5 rewrite rules for friendly urls:
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# YOUR RULES - could be any 1 or more of something like:
# empty url
RewriteRule ^$ /path/to/your/page/
# simple /
RewriteRule ^/$ /path/to/your/page/
# ORIGINAL C5 RULES CONTINUE
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /maybe/C5/install/path/here/index.php/$1 [L]
</IfModule>
# -- concrete5 urls end --


Another approach would be to modify the end of the C5 rule [L] and add one or more rules to catch index php:
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# NOTE CHANGE TO END OF C5 RULE
RewriteRule ^(.*)$ /maybe/C5/install/path/here/index.php/$1
# NOW YOUR RULE
RewriteRule ^index.php$ /index.php/path/to/your/page/ [L]
</IfModule>
# -- concrete5 urls end --



If you try this, always keep a backup of your original working .htaccess file. When (not if) your experiments break the web server, you will need to copy it back to return to a stable and working starting point for the next experiment.