Forum Moderators: phranque

Message Too Old, No Replies

Rewrite in two steps?

Brand_Name/Blue_Widgets.htm to parser to blue-widgets.htm

         

billegal

6:59 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



I'm new to rewrite (and most other things Apache). I had created a directory structure like:

Brand_Name/Blue_Widgets.htm

I want to use:

brand-name/blue-widgets.htm

because I see that Google doesn't much care for the underscore and seems to preferentially bold lowercase URLs in SERPs but not upper or mixed case ones. (Not sure if this is generally true or just in my case.)

I think it will take me two rewrite steps.

First, I think I need to rewrite to a parser page (e.g. parse.htm?folder=Brand_Name&file=Blue_Widgets.htm).

Then I think I need to change the values from Brand_Name and Blue_Widgets.htm to brand-name and blue-widgets.htm. (Actually, this part is a little fuzzy to me because I'm not sure how to do what I want.)

Second, I need to rewrite from the parser page to brand-name/blue-widgets.htm

Is it possible to do this in one fell swoop with regex or do I need two rewrite steps? My hope is that this is so blindingly obvious that I've just missed its simplicity.

Thanks.

jdMorgan

7:14 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This thread may be useful to help you change underscores to hyphens [webmasterworld.com].

If your URLs always contain only one underscore, and it it is always in the same "area" of the URL, you won't need anything that complicated, and in that case, you probably can do the rewrite in one step.

Jim

billegal

9:20 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



Thanks for pointing out that thread. The underscoring is more complicated in the example as some brand names have many words.

Any insight into changing the case? Perhaps I should go one step at a time.

jdMorgan

11:30 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can do the case-changing easily if you have access to httpd.conf (server configuration). If not, then I'd suggest using a script-based solution rather than using mod_rewrite. Perl or php have direct capability to do case and character substitution; doing both of these in .htaccess using mod_rewrite would be fairly inefficient.

As far as going one step at a time, the first step is to define precisely what needs to be done.
Then define what "tools" can be used to reach that goal, i.e. mod_rewrite, php, perl, etc.
Then define what needs to be done in the terms used by those tools.
Finally, implement the solution.

80 percent of the work is in the first three planning steps above, only 20 percent in the implementation.

Jim

billegal

3:36 am on Jul 15, 2004 (gmt 0)

10+ Year Member



I have httpd.conf access. I will see what I can do to change the case and implement this in one step. Thanks for the help.

jdMorgan

5:24 am on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at the tolower: function available in RewriteMap to do the case-conversion.

Jim