Forum Moderators: phranque

Message Too Old, No Replies

URL Name Changes

redo or keep the same

         

brnm98105

5:03 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



Hi I have a question, I have several urls and folders that I want to rename. For eg......

example.com/images/products/product1/abc.html
to
example.com/images/products/product1/a-black-cat.html

or

example.com/images/products/abc/
to
example.com/images/products/a-black-cat/

There are probably 50 files i want to do this to. Will this hurt?

Any help on this would be greatly appreciated.

g1smd

6:56 pm on Sep 25, 2008 (gmt 0)

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



If they are indexed and ranking, don't change them.

You lose the age, trust, and backlink profile for them.

If you really have to change them, put in a 301 redirect from the old URL to the new URL to let visitors still access the content from bookmarks, and hopefully transfer some of the ranking factors from the old to the new.

brnm98105

10:24 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



Thanks for the quick answer.

I just read up on 301 redirects. Since there are several pages I will be renaming is there a way to redirect all the changes of site that i make

I read that I need to create a .htaccess file
with something like this.....

redirectMatch 301 ^(.*)$ http://www.example.com
redirectMatch permanent ^(.*)$ http://www.example.com

does that make sense?

[edited by: phranque at 10:45 am (utc) on Sep. 26, 2008]
[edit reason] exemplified urls [/edit]

g1smd

10:30 pm on Sep 25, 2008 (gmt 0)

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



There are two parts to this:

- The URLs by which the content is referred to externally.
- The names of the folders and files on the server.

Do you want to keep the same URLs, while you internally rename the folders, or do you want to have new URLs in place of the old URLs? If the latter, will the folders on the server be renamed, or will they stay the same?

Getting that clear will then direct what will you need in the way of redirects and/or rewrites.

brnm98105

12:09 am on Sep 26, 2008 (gmt 0)

10+ Year Member



Thinking about it more I think keeping the folder names and changing the urls seems like it would be best. since the biggest reason is that the url names arent very seo frindly when i built this site 4 years ago.

g1smd

12:20 am on Sep 26, 2008 (gmt 0)

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



You will lose the age and trust of the URLs if you change them. If you really are set on doing that, then you will need a redirect from the old URL to the new URL and you will need a rewrite to connect any request for the new URL to the correct internal filepath where that content resides. You need both steps to stop any Duplicate Content issues. The redirect will then also transfer some of your trust to the new URL. It will also preserve any traffic flow coming to the old URLs from bookmarks and links on other sites.

brnm98105

1:00 am on Sep 26, 2008 (gmt 0)

10+ Year Member



Hmm. seems difficult. my head is spinning.

Theres probably not a simple htaccess script that would just do it all is there?

anyways I appreciate the help. What would you suggest?

g1smd

1:14 am on Sep 26, 2008 (gmt 0)

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



I can give you an example where there's a folder-based URL format rewriting to a parameter-based internal filepath. In the reverse, any request for a parameter-based URL is redirected to the folder-based URL format... Use it as a base to get started, and be aware that the extra steps are a good idea to do the job properly.

Your code will likely be a little more simple than this as you aren't using paramters in your URLs.

Take a simple case with two parameters, with a three and a seven digit value, and some common extra fixes that are either necessary or highly desirable:

External URL Format: www.example.com/345/1234567
Internal Server Path: /index.php?cat=345&art=1234567

# Specify acceptable index/root file. You could have a static
# index.html or allow index.php without parameters for root:
DirectoryIndex index.html index.php

# Redirect to remove trailing period or comma from URL request
# with parameters, such as from forum with autolink, and force
# www to always be in the URL:
RewriteCond %{QUERY_STRING} ^(([^&]+&)*)[.,]$
RewriteRule (.*) http://www.example.com/$1?%1 [R=301,L]

# Redirect to remove trailing period or comma from URL request
# with path, such as from forum with autolink, and force www:
RewriteRule ^(([^/]+/)*)[.,]$ http://www.example.com/$1 [R=301,L]

# Redirect two-parameter-based index.php多tml? or / URL request
# (with parameters in any order) to folder-based URL format, and
# force www to always be in URL:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.(php多tml?))?(\?[^\ ]*)\ HTTP/ [NC]
RewriteCond %{QUERY_STRING} &?cat=([0-9]{3})&?
RewriteCond %1>%{QUERY_STRING} ^([^>]+)>([^&]*&)*art=([0-9]{7})&?
RewriteRule ^(index\.(php多tml?))?$ http://www.example.com/%1/%3? [R=301,L]

# Force all remaining requests for named index files to drop
# the index file filename, and force www:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?如hp)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?如hp)$ http://www.example.com/$1 [R=301,L]

# General rule to force all non-www URLs to be www URLs.
# This rule must be the last one of the redirects:
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# Rewrite such that stray parameters or value names on any index.html?
# or any index.php URL or on / URL request always fail to the
# 404 page:
RewriteCond %{QUERY_STRING} .
RewriteRule ^(index\.(php多tml?))?$ /this.page.does.not.exist [L]

# Rewrite URL request: www.example.com/345/1234567 to internal
# path: /index.php?cat=345&art=1234567 to serve content:
RewriteRule ^([0-9]{3})/([0-9]{7})$ /index.php?cat=$1&art=$2 [L]

Website now only directly responds with content as "200 OK" for paths like / and /345/1234567 and all other formats either redirect or fail to the 404 Error Page if a real file does not exist. It does this without having to do server-intensive !-d and !-f checks on the filesystem.

The site root can be implemented either as a static index.html page or by using index.php without any parameters. The script will also need to check that parameters are present, and that the values are acceptable, and fail to the internally script-generated 404 Error Page if not.

The rules in the .htaccess file restrict certain URL requests from ever reaching the filesystem on the server. They are redirected or failed to a 404 immediately.

[edited by: phranque at 10:46 am (utc) on Sep. 26, 2008]
[edit reason] disabled smileys ;) [/edit]