Rewrite url using regex in apache

I have just moved a site from IIS to Apache and from asp to PHP however I don’t want to have dead links all over the place I been reading about rewriting with regex but have not been able to make it work basically I had URLs that looked like this

http://www.medialifemagazine.com/artman2/publish/The-coming-fall-season/For-Fox-a-newfound-stability-this-fall.asp

and now they are like this

http://www.medialifemagazine.com/The-coming-fall-season/For-Fox-a-newfound-stability-this-fall/

I have this so far but it does not work

RewriteRule ^artman2/publish/([a-z]+) /([a-z]+)\.asp$

this part is always the same

http://www.medialifemagazine.com/artman2/publish/

and this part always changes /The-coming-fall-season/For-Fox-a-newfound-stability-this-fall.asp

any help is appreciated

Amigo,

Have you read the tutorial linked in my signature? There are two bits of sample code which would help, the first in defining character ranges and the second if replacing file extensions. To make a long story short, all you need is:

# .htaccess in DocumentRoot

RewriteEngine on

# Replace extension for directory/filename in artman2/publish directory
# Note: Apache 2.x assumed
RewriteRule ^artman2/publish/([-a-zA-Z]+)/([-a-zA-Z]+)\\.asp$ artman2/publish/$1/$2.php [R=301,L]

What you were missing was the leading - and uppercase characters in the character range definitions (and a redirection in your RewriteRule).

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK

I tried your rewrite and went through the link in your signature and still can’t get it to work, I modified the rewrite you gave me as the structure is different but even trying yours the url does not change this is all I have right now in the htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^artman2/publish/([-a-zA-Z]+)/([-a-zA-Z]+)\.asp$ index.php/$2/ [R=301,L]

why would it not follow the rewrites?

Now I feel a little retarded, I guess I need to sleep a little more, I did not uncommented mod_rewrite, although reading that post in your signature did help and also the rewrite rule you helped me construct, thank you

:tup:

Regards,

DK