I know this may have been addressed in the past, I need to explain why I need to figure this out.
When someone visits our site, they land on the www.thesite.com and you happen to have a Facebook, or AddThis and the like.
The visitor clicks like and all is good, now as the member/visitor navigates the site, and goes back to the home page, it is always re written as "www.thesite.com/index.php" therefore making the Facebook like counts vary, looks very stupid.
Main page has thousands of likes, when navigating and getting back to the index, it show maybe 78 likes or so.
How can I make the site always just show the www.thesite.com when on the index page without the "index.php?"
ManOfTeal.COM a Proud UNA site, six years running strong! |
oh well probably redirect all visits to index.php -> /
EDIT: This is something. Not tested at all
if(strpos($_SERVER['REQUEST_URI'], 'index.php') !== false) header('Location: '.BX_DOL_URL_ROOT.'');
Put that in index.php anywhere after 'header.inc.php' is included.
so much to do.... |
You can try this.
Edit index.php.
Right after this line.
define('BX_INDEX_PAGE', 1);
Add this line.
if($_SERVER['REQUEST_URI'] == '/index.php') header ('Location: /');
NOTE: I have not tested this under all conditions. But seems to work. It allows URLs that contain get params which it should, so it should be ok.
https://www.deanbassett.com |
oh well probably redirect all visits to index.php -> /
EDIT: This is something. Not tested at all
if(strpos($_SERVER['REQUEST_URI'], 'index.php') !== false) header('Location: '.BX_DOL_URL_ROOT.'');
Put that in index.php anywhere after 'header.inc.php' is included.
Ah, you must have edited your post. I did not see your code before.
https://www.deanbassett.com |
I've been out all day on service call.
Thanks for the super fast response guys. I'm about to apply this and check.
Thumbs up from me.
ManOfTeal.COM a Proud UNA site, six years running strong! |
ManOfTeal.COM a Proud UNA site, six years running strong! |
This should be a core change.
This really affects all social share links from any sites index page.
ManOfTeal.COM a Proud UNA site, six years running strong! |
It worked fine? you tested it very well?
I had a feeling its not enough.
so much to do.... |
I do it in the .htaccess as a permanent redirect. You can put this under RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.yoursite.com/ [R=301,L]
I think this might be better from an SEO point of view. Google used to dislike php redirects but they change what they like and dislike about once a month so who knows.
I know this may have been addressed in the past, I need to explain why I need to figure this out.
When someone visits our site, they land on the www.thesite.com and you happen to have a Facebook, or AddThis and the like.
The visitor clicks like and all is good, now as the member/visitor navigates the site, and goes back to the home page, it is always re written as "www.thesite.com/index.php" therefore making the Facebook like counts vary, looks very stupid.
Main page has thousands of likes, when navigating and getting back to the index, it show maybe 78 likes or so.
How can I make the site always just show the www.thesite.com when on the index page without the "index.php?"
BoonEx Certified Host: Zarconia.net - Fully Supported Shared and Dedicated for Dolphin |
Ok, i tested and as i thought ajax request was the problems. Here you go..
The better code with mscott recommendation.
if(strpos($_SERVER['REQUEST_URI'], 'index.php') !== false && !isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest') { header ('HTTP/1.1 301 Moved Permanently'); header('Location: '.BX_DOL_URL_ROOT.''); exit; }
EDIT: Put this just before "check_logged();" in index.php.
This should play better with google cuz its a 301 redirect.
Enjoy!
so much to do.... |
It worked fine? you tested it very well?
I had a feeling its not enough.
Yes, been testing all night.
I think this might be better from an SEO point of view. Google used to dislike php redirects but they change what they like and dislike about once a month so who knows.That does not bother me. I'd rather have "true" likes, I do just fine on the SEO part.
ManOfTeal.COM a Proud UNA site, six years running strong! |
From a compatibility point of view, which is the better option, Prashanks or MScotts code?
If Prashanks, where exactly do you put the code as it did not work when I tried it.
Stuart
There are none so blind as those that will not see. |
I suppose mscott code doesn't take ajax calls in consideration like our old piece of code so i think mine is more "compatible".
Oh and i edited the above post to tell where to put it.
From a compatibility point of view, which is the better option, Prashanks or MScotts code?
If Prashanks, where exactly do you put the code as it did not work when I tried it.
Stuart
so much to do.... |
Many thanks for that!
I liked MScott's htaccess way of doing things, it bypass's the 'updates' problem! However, re compatibility I have implemented your solution.
Is there a way to do this for ALL the url's?
Stuart
I suppose mscott code doesn't take ajax calls in consideration so i think mine is more "compatible".
Oh and i edited the above post to tell where to put it.
From a compatibility point of view, which is the better option, Prashanks or MScotts code?
If Prashanks, where exactly do you put the code as it did not work when I tried it.
Stuart
There are none so blind as those that will not see. |
what?
Is there a way to do this for ALL the url's?
so much to do.... |
I still get stuff like "m/listing/home/", is there a way to clean this up in the same way we have done with the index page? There are none so blind as those that will not see. |
well, nop. You can search the forum for some ways to remove "m" from the url thats max that can be done. so much to do.... |
Ok, thanks Prashank.
Stuart
well, nop. You can search the forum for some ways to remove "m" from the url thats max that can be done.
There are none so blind as those that will not see. |
I changed mine to the new fix and it still works. Thanks! ManOfTeal.COM a Proud UNA site, six years running strong! |