0

i have to redirect some links to a standard one like:

/lang/news1
/lang/news2
/lang/news3 to /lang/news.html

Now i don't want to set redirect 301 directly on htaccess (i have 500 links) 
and i read the possibility to create a rewritemap and a rewrite rule for the map, but how?

I read on all internet but i don't understand how to do that.

Suggestions?

Gabriele

1 Answers1

0

I'd suggest put something like this into your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lang/
# redirect everything looks like `news[digits]` to `news.html`
# this will NOT change the request url
RewriteRule ^news([0-9]{1,})$ news.html [L]
</IfModule>

Your host server has to support mod_rewrite of course.

Zodiase
  • 13
  • 3
  • Hi,thnaks for your help! But i can't do that becasue i have also other urls on /lang that i don't want to redirect...First on my server there was a wordpress site and now i have a joomla site. Thw wp site create some links that i have to redirect in the new installation with joomla i re-created the links for multilingual /ita and /eng and in /ita i have also some links that i have to keep in my sitemap... – Gabriele Tramonti Jul 26 '13 at 09:35
  • The code I suggested should only redirect `/lang/news1`, `/lang/news2`, `/lang/news3` and alike to `news.html`. It won't affect `/lang/book1` since it doesn't match the rule. Say if you only want to redirect news1, 2 and 3, literally, without redirecting news4, then change the rule to `^news(1|2|3)$`. Anyway, there has to be a regular expression that matches your requirement, I suppose. :-) – Zodiase Jul 26 '13 at 09:48
  • Maybe i espress this situation very bad! :) The problem is: i have 200 news that have title like: /ita/serata-mondiale-per-una nuova-costruzione that i want to redirect to news.html ... i don't know if with a regualr regex i can include all cases.. Thanks! – Gabriele Tramonti Jul 26 '13 at 10:07
  • If they are all random enough and you don't see an easy match, well... Maybe I would have a better idea if you explain your goal more in detail. Why do you want to do this? – Zodiase Jul 28 '13 at 20:24