Meo
Meo

Reputation: 241

Mod_rewriter simple redirect

I need some help with mod_rewirter

My URL have this structure http://mydomain.com/post.php?id=122/year/month/title/

i need to have the new link:

http://mydomain.com/year/month/title/ how can i do this with mod_rewriter, please can you help me! thank you

Upvotes: 0

Views: 61

Answers (1)

onatm
onatm

Reputation: 846

http://corz.org/serv/tricks/htaccess2.php it is a nice page to learn apache mod_rewrite engine.

And i'll give you an example while i'm still insisting that you have to add id on your seo friendly url

RewriteRule ^/([0-9]+)/([0-9]{4})/([0-9]{2})/([A-Za-z0-9-]+) http://mydomain.com/post.php?id=$1/$2/$3/$4/ [NC]

If we suppose you can get values in order to date

RewriteRule ^/([0-9]{4})/([0-9]{2})/([A-Za-z0-9-]+) http://mydomain.com/post.php?year=$1&month=$2&title=$3 [NC]

Also, you can validate any regex on this link: http://www.regular-expressions.info/javascriptexample.html or that: http://www.gethifi.com/tools/regex

Upvotes: 1

Related Questions