YaBB Community and Support Forum
YaBB Home About YaBB Download YaBB YaBB Support Customize Your Forum Development Contribute to the Project

This Codex is Read Only, there is No reason or requirement to Login to view any and all posts.

FoxLingo Afrikaans Arabic Bulgarian Catalan Chinese Simplified Chinese Traditional Croatin Czech Danish Nederlands/Dutch Esperanto Filipino Finnish French German Greek Hebrew Hungarian Icelandic Indonesian Italian Japanese Korean Norwegian Polish Portuguese Portuguese Brazilian Romanian Russian Serbian Slovenian Spanish Swedish Thai Turkish Welsh
  HomeHelpSearchLogin  
 
 
Page Index Toggle Pages: 1
Print
URL Redirection ... when needed (Read 3729 times)
URL Redirection ... when needed  {yabbadmin}
URL Redirection

The configuration directives discussed in the above sections tell Apache to get content from a specific place in the filesystem and return it to the client. Sometimes, it is desirable instead to inform the client that the requested content is located at a different URL, and instruct the client to make a new request with the new URL. This is called redirection and is implemented by the Redirect directive. For example, if the contents of the directory /foo/ under the DocumentRoot are moved to the new directory /bar/, you can instruct clients to request the content at the new location as follows:

create .htaccess file and insert this line
   
Code Select All
Redirect permanent /foo/ http://www.example.com/bar/ 



This will redirect any URL-Path starting in /foo/ to the same URL path on the www.example.com server with /bar/ substituted for /foo/. You can redirect clients to any server, not only the origin server.

Apache also provides a RedirectMatch directive for more complicated rewriting problems. For example, to redirect requests for the site home page to a different site, but leave all other requests alone, use the following configuration:

   
Code Select All
RedirectMatch permanent ^/$ http://www.example.com/startpage.html 



Alternatively, to temporarily redirect all pages on one site to a particular page on another site, use the following:

   
Code Select All
RedirectMatch temp .* http://othersite.example.com/startpage.html 


 

Re: URL Redirection ... when needed  {yabbadmin}
Code for an index.html (or .htm depending OS and default document setting) - to go in the top level (root) of your site.

Code (HTML)Select All
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Forum Redirect</title>
<meta http-equiv="refresh" content="1;URL=http://www.yourdomain.com/cgi-bin/yabb2/yabb.pl">
</head>

<body>

<p>You are being redirected</p>

</body>

</html>  



  Change or Modify the highlighted address above to match your URL to your forum.

or:
Code (HTML)Select All
<html>
<head>
<script language="javascript">

function OnLoad() {

    document.location.href= "http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl";

}
</script>
</head>
<body>
           You're being redirected .....
</body>
</html>
 


 

Re: URL Redirection ... when needed  {yabbadmin}
If wanting to use Apaches Mod_Rewrite (Module MUST be loaded to the server)

in .htaccess
Code Select All
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index\.html$ YaBB.pl
 


or
Code Select All
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index\.html$ http://www.yourdomain/cgi-bin/yabb2/YaBB.pl
 



* Although highly unlikely, your host may have +FollowSymLinks enabled at the root level, yet disallow its addition in .htaccess; in which case, adding +FollowSymLinks will break your setup (probably a 500 error), so just remove it, and your rules should work fine.

Though this is the simplest example possible, it may throw a few people off. The structure of the ‘old’ URL is the only difficult part in this RewriteRule. There are three special characters in there.

   * The caret, ^, signifies the start of an URL, under the current directory. This directory is whatever directory the .htaccess file is in. You’ll start almost all matches with a caret.
   * The dollar sign, $, signifies the end of the string to be matched. You should add this in to stop your rules matching the first part of longer URLs.
   * The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didn’t escape it with the backslash, which tells Apache to treat it as a normal character.

So, this rule will make your server transparently redirect from Index.html to the YaBB.pl page. Your reader will have no idea that it happened, and it’s pretty much instantaneous.

Forcing New Requests

Sometimes you do want your readers to know a redirect has occurred, and can do this by forcing a new HTTP request for the new page. This will make the browser load up the new page as if it was the page originally requested, and the location bar will change to show the URL of the new page. All you need to do is turn on the [R] flag, the NC is non case sensitive by appending it to the rule:

Code Select All
RewriteRule ^old\.html$ new.html [R, NC]  



   e.g. (.+)\.html? matches foo.htm and foo.html
        (foo)?bar\.html matches bar.html and foobar.html

further info here: Rewrite Rule Tutorial

 

Page Index Toggle Pages: 1
Print

Get Yet another Bulletin Board at SourceForge.net. Fast, secure and Free Open Source software downloads Support This Project BoardMod - YaBB features and templates YaBB Codex - support on installation and usage YaBB Toolbar for your browser YaBB Facebook Group Page

Valid RSS Valid XHTML Valid CSS Powered by Perl
YaBB Support Codex » Powered by YaBB Next Edition!
YaBB Forum Software © 2000-2011. All Rights Reserved.