Simple Machines Community Forum

Archived Boards and Threads... => Archived Boards => Mambo Bridge Support => Topic started by: smashingyoungman on January 05, 2006, 01:25:39 AM

Title: Redirect an unwrapped page to a wrapped via htaccess
Post by: smashingyoungman on January 05, 2006, 01:25:39 AM
I've been playing around with doing this on my site, and I've gotten close to the desired results, but I'm still not able to get it just right. The general idea is to have the "/forum/index.php" redirect to the wrapped url, such as "/component/option,com_smf/Itemid,62/". Any htaccess gurus here that might have better luck with this?
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: Orstio on January 05, 2006, 01:35:51 AM
You do not want to do that by .htaccess.  That would create numerous issues.

Put something like this in your SMF index.php:

// Redirect users who try to access /forum directly
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
        if(!defined('_VALID_MOS')){ header("Location: http://portal.myurl.com/index.php?option=com_smf&Itemid=yourItemidNum");}
}
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: smashingyoungman on January 05, 2006, 09:40:47 AM
Lol...that was disappointingly simple. Thanks, Orstio.  :D
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: maxigs on October 30, 2006, 10:33:49 AM
I'm just about to be in the same kind of situation here:

I have the board running since a few month now and not the CMS is about to be finished so the board-view hat to be moved into the wrapped one.

So far its like this:

mydomain.com/forum -> smf-root
mydomain.com/portal -> cms-root

and therefore the new wrapped path will be something like this:

mydomain.com/portal/index.php?option=com_smf&Itemid=xx...

Orstios modification to the index.php would redirect everthing just to the board-index, no matter where with what link they came from, right?
I'd rather have the old links dynamically redirected to the new path - i hate it by myself when sites are changing their urls, so i dont want to put my guests in the same situation.

Is there any good way in doing this? The .htaccess-redirect causes problems?
What about extracting the necessary parts of the url and just attaching them again in Orstios example?
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: Kindred on October 30, 2006, 11:03:48 AM
yes, using htaccess will cause LOTS of problems.
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: maxigs on October 30, 2006, 12:12:21 PM
Quote from: Kindred on October 30, 2006, 11:03:48 AM
yes, using htaccess will cause LOTS of problems.

so you would recommend the header output through php like orstio mentioned?

i still would like to have the redirection to the proper content and not just to the board index if this is possible.
or is there any way of "good" seo for this problem? yet i did not find any ;)

if the htaccess causes problem ist this because of the "redirect" statement? what about a url-rewrite instead (from "/forum/index.php?" to "/portal/index.php?option=com_smf&Itemid=xx&") ?

sorry for asking so many questions at once but i would like to get this "problem" fixed in the best possible way ;)
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: Kindred on October 30, 2006, 01:42:28 PM
no using re-write will also mess things up, majorly.


You should use the "in-code" redirect...


Do a search. I think someone came up with a way to redirect to specific pages "in-code"..


But does that really matter?   Think about it...  who uses a url going specifically to an individual message?   Most (if not all) people go to the baord index and then work their way through the boards & messages.
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: maxigs on October 30, 2006, 06:03:49 PM
Quote from: Kindred on October 30, 2006, 01:42:28 PM
But does that really matter?   Think about it...  who uses a url going specifically to an individual message?   Most (if not all) people go to the baord index and then work their way through the boards & messages.

yet i dont kow how much it would matter, but still i would like it to work for everyone, i guess ill follow your advice and look for the code, otherwise just make the redirection to the index. since the communitiy is not to big yet it might not be to bad yet ;)

btw just for my interest: how does it mess the smf up with the redirect?
if i see the funktion right its just sending a new url to the browser where the content page has been moved and then the browser is opening the new wrapped page is. so for the smf itself it does not make any change (except of everything NOT beeing the index.php, and this could be escaped by the rewrite rule also).
Title: Re: Redirect an unwrapped page to a wrapped via htaccess
Post by: Orstio on October 30, 2006, 06:21:53 PM
Quotebtw just for my interest: how does it mess the smf up with the redirect?

There are still a few things that need to access the forum directly in order to work properly.  Attachments and the CAPTCHA code in the SMF registration are two examples of that.  If your forum happens to be in a subdomain, redirecting with .htaccess away from the subdomain URL will cause the cookie set to fail.