2

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?

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

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.

6
  • Hi would the term "RedirectMatch" work in htaccess? Thanks a lot! Jan 26 '14 at 4:41
  • Hi tried adding the line above to .htaccess and it didn't work! Please assist. Thanks! 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! 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. Jan 26 '14 at 5:06
  • It adds url to the new url: Jan 26 '14 at 5:45
0

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.

0

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.