1

I need to convert links such as

http://www.example.co.uk/blog/archive.php?date=2012-05

to

http://www.example.co.uk/blog/archive/2012/05/

using php or .htaccess file.

.htaccess file

RewriteEngine on
RewriteRule ^blog/archive/([0-9]+)/([0-9]+)/$ http://www.example.co.uk/blog/archive.php?date=$1-$2 [NC]

Ive have tried this but not having any luck. Any ideas or help would be appreciated.

7
  • Do you get a 404 when accessing the url? Is there anything else in the htaccess? Code looks fine to me. Commented May 18, 2012 at 13:31
  • Hi Gerben nothing, the code is ignored the only thing i could think of is that rewrite mod is not enabled but i would have no idea how to check this. Commented May 18, 2012 at 13:42
  • Haven't you missed out the word archive? I don't think your pattern matches Commented May 18, 2012 at 13:46
  • "archive" ... if you see what I mean. Commented May 18, 2012 at 13:46
  • Sorry forgot to add that to the example above but is in my .htaccess file, have updated code above. Commented May 18, 2012 at 13:53

1 Answer 1

1

Put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^blog/archive/([0-9]+)/([0-9]+)/?$ blog/archive.php?date=$1-$2 [NC,L,QSA]
Sign up to request clarification or add additional context in comments.

2 Comments

I get Internal Server Error 500 - I remove the top line server error goes but still doesn't work.
I have posted it after testing it on my Apache. Can you please check error.log of Apache and see what the actual error is? As a side note pls post your latest .htaccess in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.