Geesu
asked on
How do I use mod_rewrite to change example.com/1/2/3 to example.com/3 ??
Is this possible?
Lets say I have this URL:
http://example.com/1/2/3/
And I want to use mod_rewrite to make it look like:
http://example.com/3/
Or is this not possible?
Thanks!
Josh
Lets say I have this URL:
http://example.com/1/2/3/
And I want to use mod_rewrite to make it look like:
http://example.com/3/
Or is this not possible?
Thanks!
Josh
it should be
RewriteEngine on
(missing 'e')
RewriteEngine on
(missing 'e')
ASKER
woa thats confusing, don't think I can do this myself...
Well basically what I need the rule to be like will depend on what is clicked on... (I have a web archiving website)...
So one link will be:
example.com/data/March-200 6/20/thesi tewillbehe re/
which will be re-written as:
example.com/thesitewillbeh ere/
And the March-2006 and the 20 can change dynamically as well as the folder name for "thesitewillbehere", is this possible to do with a rule?
Well basically what I need the rule to be like will depend on what is clicked on... (I have a web archiving website)...
So one link will be:
example.com/data/March-200
which will be re-written as:
example.com/thesitewillbeh
And the March-2006 and the 20 can change dynamically as well as the folder name for "thesitewillbehere", is this possible to do with a rule?
if you access example.com/data/March-200 6/20/thesi tewillbehe re/ you can rewrite it to example.com/thesitewillbeh ere/ (so example.com/thesitewillbeh ere/ exists physically) the other way /data/March-2006/20/thesit ewillbeher e/ exists but you're calling /thesitewillbehere/ will not work. You must use a RewriteMap or a rule for each string in that case.
RewriteEngine on
# /data/March-2006/20/thesit ewillbeher e/ --> /thesitewillbehere/
RewriteRule ^data/[^/]+/[^/]+/([^/]+)/ $ /$1/ [L]
RewriteEngine on
# /data/March-2006/20/thesit
RewriteRule ^data/[^/]+/[^/]+/([^/]+)/
ASKER
Is it possible to have thesitewillbehere be the same???
In theory that directory is supposed to be the same each month this tool runs... SO I guess I should try to make them different?
For example maybe doing like example.com/data/March-20- 2006-thesi tewillbehe re which I can then re-write as example.com/March-20-2006- thesitewil lbehere
These directories are created dynamically each month, so is it possible to auto-add a new rule everytime a directory is created? Or is there a way to make this not necessary?
In theory that directory is supposed to be the same each month this tool runs... SO I guess I should try to make them different?
For example maybe doing like example.com/data/March-20-
These directories are created dynamically each month, so is it possible to auto-add a new rule everytime a directory is created? Or is there a way to make this not necessary?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow dude thanks, I need to learn regular expressions it seems :)
RewriteEngin on
# rewrit incomming request /3/ --> /1/2/3
Rewriterule ^3/$ /1/2/3/ [L]
are you planning to use that in a .htaccess file or in httpd.conf?