Forum Moderators: phranque

Message Too Old, No Replies

Force To Upper case .htaccess

         

flanok

3:46 pm on Sep 25, 2008 (gmt 0)

10+ Year Member



Hi

First I must say, thta although I know what an .htacess file is and why we use it, my knowledge of hpw to a command together is very poor, so i am looking for advice.

I need to redirect or rewrite one folder in the rule from lower case to upper case.

My existing estblished url is like this

myurl/Car/UPPERCASE/

or

myurl/Car/UPPERCASE/More-files-here/

I am only iterested in the UPPERCASE area.

I have been lucky enough to recieve a lot or links to all the uppercase catergories.

However I have recently has a rankings drop and so have noticed that all these links, link to me using lower case i.e. myurl/Car/uppercase/

the content for theses page are generated, and so delivers 2 different sets of content for the same url written either in lower case or lower case.

I have tried a standard 30 direct, but it adds presents a string at the end of /UPPERCASE/ in the browser I did not create

i.e. /UPPERCASE/?unwritten string about catagories in site

So i think I need a rewrite that will always rewrite the /UPPERCASE/ file to lowercase. i.e/ myurl/Car/uppercase/

can anyone help, knowing I know litle about how to write this.

thanks

Mark

g1smd

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

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



A rewrite allows the user to see the content, but the browser continues to show the incorrect URL for that resource. That's another duplicate content issue.

A redirect forces the browser to make a new request for the content, but at the correct URL for it. This is much more friendly to search engines and users.

Based on that, which one do you actually want?

flanok

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

10+ Year Member



hi
Based on what you have said, a redirect.

thanks

Mark

jdMorgan

3:41 pm on Sep 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The solution available in mod_rewrite for this problem is going to be very slow and inefficient. The problem would be much easier to fix if you have server-config-file access.

Also, if you have any other URLs in the form /w/x/y or /w/x/y/z (which match your UPPERCASE examples), then you will need to do one of two things: Either specifically list all UPPERCASE directories which are currently linked-to incorrectly as lowercase, or list all *other* URL-paths that *do not* need to be forced to uppercase.

This is necessary because otherwise, second-level directory-path-part (the "x" in my example URL-path templates above) will always be forced to uppercase, even if the request was for (as an example) "/images/logos/widgetcom.gif".

Another possibility is that you may be able to use some other attribute of the requested URL to allow the code to decide whether or not to force uppercase. An example would be, "if the top-level directory is 'Car', then force uppercase in the second-level directory", or something similar. Since we're not familiar with your URL-architecture, only you can answer this question.

Again, the solution to this problem is going to be complex, and very slow and inefficient. If this were my site, I would get started now to adopt all-lowercase URLs for future use. In fact, I would change my directory filepaths to all-lowercase, and redirect any and all requested URLs containing uppercase characters to all-lowercase, instead of the other way around, as we're discussing here.

Jim

flanok

7:09 pm on Sep 27, 2008 (gmt 0)

10+ Year Member



Hi

Thanks for the reply.

I do have access to the server.

I accept the urls should all be lower case, it is just too late in my opinion to risk doing it

We have over 4000 uniques every day and until this isse became apparent, were number one for as competitive term

To change the urls, represents to much of a risk.

I have found a redirect that takes the inacurate incomming links that create the page to a 404.
It means I lose link value (probaly never had it anyway).
But that is less risky than having duplicate(similar) content pages or urls.

Thanks again for you reply.

Mark

g1smd

7:21 pm on Sep 27, 2008 (gmt 0)

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



I don't like the sound of the 404 solution.

I would be linking to all-lower-case and redirecting to lower-case for external incoming upper-case requests. Can you try it on a small part of the site?

jdMorgan

8:49 pm on Sep 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, this is just an opinion: Sure it's a risk to fix things now with 4,000 uniques per day. But how about next year, if you're getting 8,000, or 160,000 uniques: Will it be better then? If you don't fix the problem, will your traffic grow to make it more of a problem?... Who knows?

If you adopted all-lowercase URLs page-by-page or small-section-by-section over the next several months, temporary loss of ranking would be a non-issue. In addition, you could use a RewriteMap in httpd.conf (or other server-config file, not available in .htaccess) to call the operating system's tolower function, fixing all uppercase characters all at once. If you retain capital letters, then you have to use some kind of exclusion, for example, do not lowercase the initial letter of each URL-path-part (as defined by the slashes).

You might also want to look into mod_speling as an alternative to mod_rewrite. Performance testing should quickly tell you whether the mod_rewrite or mod_speling option is better.

At any rate, you probably want a 301 redirect in order to retain your PageRank/Link-popularity/TrustRank.

Jim