Page 1 of 1

how to make the default page visible in the address bar and menus

Posted: Fri Nov 14, 2008 12:11 pm
by alinome.net
The situation

Two CMSMS sites of mine (versions 1.3.1 and 1.2.5). They use pretty URLs with mode_rewrite.

What CMSMS does:

Let's say my default page is mydomain.com/last_news. All links to the default page point to the root "mydomain.com". And when I visite mydomain.com I am redirected to last_news... though the browser's address bar keeps showing "mydomain.com". I didn't see any problem about that -- until now.

The problem

I was putting sponsored links in the most visited pages, and of course the default page is among them. I created a personalized tag with the ads company's code and added it to the template in certain pages, depending on a content field used as flag. Everything worked fine: demo links appeared in the selected pages... except the default page: the ads company's  robot didn't find the links in it...! I had registered "mydomain.com" as the default page, so I removed it from the list and registered "mydomain.com/last_news" instead... No way: the URL was not accepted by the company because it's not indexed in Google! Of course it's not, it's hidden!

I googled into cmsmadesimple.org looking for a solution or a clue, but didn't find anything.

The solution

I thought I could solve this with the Apache's .htaccess file as usual, but the CMSMS's default page is mandatory anyway and it would interfere. I had a simpler idea:

1. Redirection tag

I created a personalized tag called "redirect_to_default":

Code: Select all

header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Status: 301 Moved Permanently' );
header('Location: http://mydomain.com/last_news');
2. Redirection template

I created an empty template "redirect_to_default", with only one line:

Code: Select all

{redirect_to_default}
3. Fake default page

I created an empty page (not really empty: one space is mandatory) called "index". Its template has to be "redirect_to_default". It must not appear in menus. Not cacheable. I marked it as the default page.

The result

Now I visit "mydomain.com" and I am clearly redirected to "mydomain.com/last_news". Also, "last_news" is showed in the menus. That's what I wanted. Now I will be able to put payed links into my default page... but I have to wait for Google to index it!!

I'm not an CMSMS expert. I wonder if there's a simpler or more elegant solution way to achieve this, or any new option in versions newer than 1.3.1. I think It would be useful to choose the desired behaviour in the site admin, with a single tick.

Cheers,
Marcos

Re: how to make the default page visible in the address bar and menus

Posted: Fri Nov 14, 2008 7:10 pm
by nhaack
Hi Marcos,

very interesting approach (for me). Thank you for posting. I might not necessarily need it for that specific reason, but it went right into my bookmarks :)

However, I think for your reason you could use just url rewriting rules and forcing a new request:

Code: Select all

RewriteRule ^old\.html$ new.html [R] 
I think in your case, the rule needs to be something like

Code: Select all

RewriteRule ^$ last_news [R] 
Hope it helps

Best
Nils

Re: how to make the default page visible in the address bar and menus

Posted: Sat Nov 15, 2008 7:47 pm
by Pierre M.
I agree it seems much simpler to 301/2 redirect / to /something at the webserver level.

Pierre M.

Re: how to make the default page visible in the address bar and menus

Posted: Sun Nov 16, 2008 3:38 pm
by alinome.net
nhaack wrote: I think in your case, the rule needs to be something like

Code: Select all

RewriteRule ^$ last_news [R] 
Thank you Nils, but it doesn't work. I already tried. It makes no difference. I think it would work if I could tell CMSMS I don't want it to manage the default page at all. Then .htaccess would do the work. I came to my template solution because .htaccess was not useful in this case (or at least I don't know how to do).

As I said, the problem is that CMSMS changes all links to the defaut page hidding the page name. That page is hidden for Google: it doesn't "exist". Of course you can access it at the root domain, but it seems it's not the same in some cases, as I discovered trying to register that page in the ads company: their program doesn't accept that page because it's not indexed by Google. If I register the root domain instead, it doesn't work: the demo ads can not be found by their "spider"; I guess the reason in this case is the CMSMS' internal redirection fools the company's "spider", I don't know.

So the only solution I've found is the internal CMSMS trick I described: to create a fake default page that never appears in menus, redirected to the desired page with a dedicated template...

I wonder if other people experimented this problem.

Cheers,
Marcos