Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
    
I've updated my answer pl. see it. –  AgA Jan 27 at 6:29
add comment

2 Answers

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.

share|improve this answer
    
Hi would the term "RedirectMatch" work in htaccess? Thanks a lot! –  user3236765 Jan 26 at 4:41
    
Hi tried adding the line above to .htaccess and it didn't work! Please assist. Thanks! –  user3236765 Jan 26 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 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 at 5:06
    
It adds url to the new url: –  user3236765 Jan 26 at 5:45
show 1 more comment

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.

share|improve this answer
    
Welcome to Pro Webmasters. –  Zistoloen Feb 26 at 10:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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