I have some URLs which are now 404 due to site upgrade.

I want all URLs starting with www.example.com/archives/* to point to www.example.com/news (notice that after archives there is a wildcard char).

Can someone here please help me with the code for .htaccess rules?

  • I've updated my answer pl. see it. – AgA Jan 27 '14 at 6:29

I assume you want to redirect permanently:

RedirectMatch 301 ^/archives/.*  http://www.example.com/news

I've placed this rule in www.tariffplansindia.com test it there.

Here is another:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com/archives [NC]
RewriteRule ^archives/(.*) http://example.com/news [R=301,L]

I've placed this rule in www.rtidiary.org test it there.

| improve this answer | |
  • Hi would the term "RedirectMatch" work in htaccess? Thanks a lot! – user3236765 Jan 26 '14 at 4:41
  • Hi tried adding the line above to .htaccess and it didn't work! Please assist. Thanks! – user3236765 Jan 26 '14 at 4:51
  • Hi I tried looking for any mention of "alias" in the .htaccess file and there is none! Can you please give me the complete code? Thanks! – user3236765 Jan 26 '14 at 4:56
  • It didn't work I added the line above into .htaccess and tried an old url that has the archives in the beginning of the url and it didn't load gave 404. – user3236765 Jan 26 '14 at 5:06
  • It adds url to the new url: – user3236765 Jan 26 '14 at 5:45

To learn about .htaccess writing rules you can refer the official link of Apache Module mod_rewrite: http://httpd.apache.org/docs/current/mod/mod_rewrite.html.

And for URL rewriting guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.