Forum Moderators: phranque

Message Too Old, No Replies

mod re-write

         

Shawn Steele

7:44 pm on May 29, 2004 (gmt 0)

10+ Year Member



Hi,

I want to re-write this url:

domain.com/category/listing-that.htm

to

domain.com/category/listing-this.htm

I can do it for dynmaic urls, but can't figure out how to re-write a static url to another static url (eg, renaming the files would take a long time). Can you help?

Thanks,
Shawn

WhosAWhata

3:35 am on May 30, 2004 (gmt 0)

10+ Year Member



if you have just that one than it is easy, but i think you probably have a lot of them...in that case you need some set of rules, exactly how every one of them changes

for that one

RewriteEngine on
RewriteRule category/listing-that.htm category/listing-this.htm

Shawn Steele

3:50 am on May 30, 2004 (gmt 0)

10+ Year Member



Here's a better explanation

I have a directory and the format is as follows:

cat - every state
domain.com/cat/arizona-widgets.htm

cat 2 every state
domain.com/cat/arizona-websites.htm

and so on for about 100 categories. So I need to change the variable after the "-" in each url so that I dont need to re-name all the files in each folder. What I wanted to do was put a htaccess file in each catregory with a rule stating to re-write widgets to websites, etc, and change the variables for each folder. Yet, all of them right now have "-widgets" but each folder is different than widgets, eg.. "-websites" or "-internets" etc. Does that make sense?

etc.

PS >> These are fictional directory structures to comply with the tos.

WhosAWhata

4:17 am on May 30, 2004 (gmt 0)

10+ Year Member



if you put a .htaccess file in your "cat" folder
it could look like this

RewriteEnguine on
#add the next line for every cat
RewriteRule (.*)-widgets.htm $1-websites.htm

this is the idea i got from your message
if this is wrong, send me a private message of your real dir structure and i'll help

Shawn Steele

4:59 am on May 30, 2004 (gmt 0)

10+ Year Member



Thank you! Worked perfect :)

corz

5:06 am on May 30, 2004 (gmt 0)

10+ Year Member



was dozing, heh..

RewriteRule ^(.*)cat/arizona-(.*).htm $1cat/arizona-widgets.htm [NC]

would catch requests to all 100 areas, it's matching only the 'websites' part.

;o)
(or