Forum Moderators: phranque

Message Too Old, No Replies

(Easy) What is htaccess for Rewrite dynamics urls oldname-id.html to newname-id.html

         

basketmen

3:54 pm on Sep 17, 2010 (gmt 0)

10+ Year Member



I want to redirect Rewrite dynamics oldname-id.html to newname-id.html , because the file name is changed


The file name is changed
the id is dynamic numbers



for example

old urls
http://www.domain.com/country-origin-Irish-page-1.html
http://www.domain.com/country-origin-Irish-page-2.html
http://www.domain.com/country-origin-Irish-page-3.html
http://www.domain.com/country-origin-Irish-page-4.html
and so on



to new urls
http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-1.html
http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-2.html
http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-3.html
http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-4.html
and so on






Please help guys what is the right htaccess for this

g1smd

4:06 pm on Sep 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What code have you tried so far?

However, one note on your plan; the new URLs are much worse than the old. The commas and underscores are a VERY bad idea.

jdMorgan

4:45 pm on Sep 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I strongly agree. There are important usability and SEO factors here.

Here, look at this URL and actually try to read it:

http://www.google.com/country origin Irlandia._Ireland,_Irish_page_1.html [google.com]

Which are spaces and which are underscores? Which are periods and which are commas? You'll likely have to hover your mouse over that link and look at the browser status bar to read it correctly...

Now ring up a friend and ask him to visit that URL. Did you get a "Sorry, what?" in that process? Quite likely you did. Did it work, or did you miss out a space or underscore in there? Very likely so...

That's the usability issue sorted, then. With my SEO cap on, I would recommend omitting the "filetype" and all non-primary keywords, and use URLs like http://www.example.com/Irish-baskets-from-Irlandia-Ireland-1

No underscores or commas to be obscured or completely-hidden by link underlining or to be mis-heard when spoken, and only the most important "keywords" in the URLs.

So:
 RewriteRule ^country-origin-Irish-page-([0-9]+)\.html$ http://www.example.com/Irish-baskets-from-Irlandia-Ireland-$1 [R=301,L]

for the redirect, and

RewriteCond $1 !(\.[a-z]+|/)$
RewriteRule ^(Irish-baskets.+)$ /$1.html [L]

on the back-end to convert these new extensionless URLs to .html filenames.

Jim