Hok's Macromedia Flash Blog

macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript

Ads

Search

Apache: modrewrite

Oh yes, if you maybe have seen i am currently rebuilding this site.
While doing that i saw, that the blog-archives-directory is outside of
the blog-folder, so i changed the moveable-type settings so that
now the archives-folder is inside the blog-folder.
But now many Links in the web would fail, so we need a redirect.



I solved this problem with two files in the old and deprecated directory.
The first is a .htaccess file which turn the server-side-rewriting of
request on, and rewrites the request to the second file.
The second file simply sends the new location by a header-command
to the client, so maybe google or other clients recognize that the url
is deprecated and store the new one.

Click the following link to see the redirecting in action:
http://www.flashfanatiker.de/archives/000037.html

.htaccess
# Turn the RewriteEngine on
RewriteEngine On

# Rewrite only if we are not accessing
# our redirection-php-file
RewriteCond %{REQUEST_URI} !^.*rewriter.php$

# match all and attach it as path-get-variable
RewriteRule ^.+$ rewriter.php?path=$0

rewriter.php
if ($_GET['path'] == 'files/treeTraceGlobal.htm' ||
$_GET['path'] == 'files/treeTrace.as')
header('Location: http://www.flashfanatiker.de/blog/'. $_GET['path']);
else
header('Location: http://www.flashfanatiker.de/blog/archives/'. $_GET['path']);

Posted by hOk at January 8, 2004 02:03 PM

Comments (0)


Name:


Email Address:


URL:


Comments:



You can use <code>code that should be highlightned</code> to highlight code!
Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise
actionscript-highlightning will be used.

New Place