Closed Thread Icon

Topic awaiting preservation: Redirect with RewriteRule Pages that link to <a href="https://ozoneasylum.com/backlink?for=12903" title="Pages that link to Topic awaiting preservation: Redirect with RewriteRule" rel="nofollow" >Topic awaiting preservation: Redirect with RewriteRule\

 
Author Thread
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 09-23-2003 17:47

Hi,
i want do redirect from a directory (that doesn't exist) to a specific file.

from:
2003/09/22/
to:
index?data=2003/09/22

This is my RewriteRule:

code:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule 200([0-9])/([0-9]*)/([0-9]*) index.php?data=200$1/$2/$3


But that does not work as i expect. Any hints? Solutions?
Thank you.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 09-23-2003 18:01

u-neek: It looks OK but with these things you need to keep tweaking - try:

code:
RewriteEngine on
RewriteBase /
RewriteRule 200([0-9])/([0-9]*)/([0-9]*) /index.php?data=200$1/$2/$3 [L]



[edit: Also as seem to want to have the URL 2003/04/05 then you need to specifiy that the numbers need to be found one or more time so change them to [0-9]+ - if you want to be able to have links like 2003/ or 2003/05/ etc. then you will need to fiddle with things a bit more:

code:
RewriteEngine on
RewriteBase /
RewriteRule 200([0-9]+)(/)?([0-9]*)(/)?([0-9]*) /index.php?data=200$1/$3/$5 [L]



keep fiddling - you'll get there ]

___________________
Emps

FAQs: Emperor

quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 09-23-2003 20:17

I am still almost totally clueless on this. Say I want to make:
website.com/a/b/
redirect to:
website.com/?first=a&second=b
How would I go about it. I understand .htaccess etc. but don't fully understand how to write the rules. Maybe we need a FAQ...

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 09-23-2003 20:37

quisja: Your answer is essentially the same as u-neek's above but instead of [0-9] you use [a-zA-Z] - the three keys to understaning things are:

1. Understanding regular expressions.

2. Planning out what you want to do in advance (usually describing a regular expression virtually write it).

3. Tweaking things until they are right - usually things are either working on broken and there is no inbetween which allows you to refine things.

I will be writing a tutorial for the GN on this (technically its all sketched out but still needs some work) its not really something that can be comfortably dealt with in a FAQ - most examples are very specific to what you want to do.

___________________
Emps

FAQs: Emperor

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 09-24-2003 15:27

Thanks.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 09-24-2003 15:36

u-neek: Did that work? If so which version?

___________________
Emps

FAQs: Emperor

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 09-24-2003 15:55

Mod rewrite is a monster of an Apache mod. Possibly the most difficult to understand because of the weird way it flows. The best reference is the Apache manual itself. See http://httpd.apache.org/docs/mod/mod_rewrite.html and also http://httpd.apache.org/docs/misc/rewriteguide.html

Not that those two references are easily digestible. I spent many hours pouring over them and tweaking on some rules to get what I wanted, but it still took a lot of trial and error testing. Like Emp says, you just have to have the patience to do a lot of tweaking, because sometimes simple things like leading slashes or the fact that query strings don't literally appear in the internal URLs can really throw you.

-jiblet

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 09-24-2003 17:10

I don't know which version of them worked, i've used a mix between your 1st and 2nd version. My host doesn't support the XSLT functions. So i cancelled the project on which i was working on and deleted the lines in my .htaccess.

« BackwardsOnwards »

Show Forum Drop Down Menu