Forum Moderators: phranque

Message Too Old, No Replies

I want to shorten my ugly URL

Not sure how to do it

         

BinkyM

8:52 pm on Jul 22, 2005 (gmt 0)



Folks:

I want users of my site to see this in their address bar:

[domain.com...]

Instead of what theyr'e seeing now:

[domain.com...]

I figger I'll deal with "ugly&stuff&is&here" later, but for now, I'd really like to remove, at minimum, the two directories.

I *believe* I wanna alias, but I'm not sure how. And I've been reading docs about mod_rewrite for two months now, and feel as if I know even less now about it than I did when I started! (How inscrutable it is!)

I'd be really grateful for an explanation geared toward a dummy. Thanks!

jdMorgan

10:17 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BinkyM,

Welcome to WebmasterWorld!

The first step is to modify your ikonboard code so that it puts "friendly" URLs on your pages.

Step two is to use mod_rewrite to rewrite (not redirect) those friendly URLs, when requested by visitors or search engine robots, back to your ikonboard cgi script with the necessary query-string parameters taken from the "friendly" URL.

The third optional step, if you're concerned about search engine ranking, is to redirect (not rewrite) the ugly URLs to the friendly ones. This will clean up your search engine listings faster, but is not sufficient by itself to get the whole job done.

We've had tons of threads here on this subject, so try a search [google.com] for more info.

Jim

BinkyM

10:40 pm on Jul 22, 2005 (gmt 0)



jd:

(While attempting to reply to your post, I am shown *mine*, which makes quoting tricky!)

> The first step is to modify your ikonboard code so that it puts "friendly" URLs on your pages.

I am not loving you right now, jd. I'm trying to remind myself you're just the messenger, though. Besides, when it comes right down to it, I understand the Ikonboard software better than I understand mod_rewrite, that's fer sure, so I guess I can tackle that. I was looking for a nice, quick, easy, single-line fix. (sigh) It's never that easy, is it?

Hokay; lemme try something else on you, then: I output my links for RSS feeds and they usta work nicely, too. At some point (I don't know why), they quit working. That's because the semi-colons in the URLs I'd been outputting were magically turning into ampersands on their way back in (ie, when a user clicked a link), so the user gets a 404.

Now, I *should* be able to use mod_rewrite to turn those ampersands back into semi-colons, right? (If you tell me I'm gonna hafta modify Ikonboard's output some more, I'm gonna cry, scream, and kick, and then my nose'll be all snotty and my mascara will make me look like Anna Nicole Smith. We don't want that, right? So be gentle!)

jdMorgan

11:19 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well the key is that the 'real' URL is the URL seen (and clicked) on your pages. You can use mod_rewrite to "fix" some things, but it's important to remember that mod_rewrite works *after* a URL request arrives at your server, and *before* any content-handlers are invoked (e.g. the ikonboard script) or any content is served; it is a 'front-end' process, not a 'back-end' one; It cannot change the pages output from your server. So the URL that appears on your page is *the* URL seen by the world, and listed in search engines. mod_rewrite can be used to either redirect that requested URL, invoking a new client HTTP request, or it can be used to 'translate' the URL into a filename that is not necessarily the same as the URL-path given by the URL.

So, yes, you can 'fix' the semicolon-ampersand thing, but it would be better to find the root cause and fix that. I don't subscribe to the "If all you have is hammer, everything looks like a nail" approach to site configuration, and doing so only leads to (changing metaphors) putting band-aids on band-aids. Where mod_rewrite will be most useful to you is in fixing search engine listing problems caused by server misconfiguration, and in converting "friendly" URLs back to the form needed to invoke your script.

The ease with which mod_rewrite can be used to fix your ampersand problem will depend on how many characters are 'wrong' in each URL; It gets very inefficient if there are more than three or four.

What's ikonboard written in? If it's PHP or PERL, you can use their regular-expressions-based string substitution operators to create friendly URLs on the fly, and then we can discuss any implementation problems on the mod_rewrite end as they arise.

You can post example URLs to explain the RSS problem. Just use "example.com" as the domain name, and that will keep you within the WebmasterWorld Terms of Service. What do you see when you hover over a link on your page? -- that will help detemine where the problem lies.

The function of WebmasterWorld's "reply to" screen is intentional. It is meant to keep posts on-topic to the original thread's intent. I use a tabbed browser and often copy from several posts at a time, so I don't really notice it.

I hope the mascara is still dry...

Jim

jatar_k

11:27 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> What's ikonboard written in?

I believe the original is PERL but they do have ibPHP which is the full php version

<back to your originally scheduled thread> ;)

BinkyM

5:44 am on Jul 23, 2005 (gmt 0)



jd:

Thanks for your explanation about when to use mod_rewrite. All of the voluminous documentation on the topic tells us *how* but now when.

And yes, Ikonboard is written in Perl.

But I *do* believe my ampersand problem is solvable because all of the faulty URLs are in the same format:

http://example.com/cgi-bin/forum/ikonboard.cgi?act=ST&f=10&t=2154

Lessee; there are two ampersands there that need to become semi-colons in order for the URL to work.

Strangely, if you spot any of my pages in Google, they're all in the correct format, and they work. It is only in RSS feeds that the semi-colons become ampersands.

ALL my URLs in RSS feeds look like the example above. The only things which change are the digits (in this example, 10, which is the forum number, and 2154, which is the topic number).

So whatcha think, Dr jd? Is there hope for me?

jdMorgan

2:15 pm on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Strangely, if you spot any of my pages in Google, they're all in the correct format, and they work. It is only in RSS feeds that the semi-colons become ampersands.

That's actually not good news. Because now we face the challenge of figuring out how to determine whether the user-agent fetching your page (to get the links) is a "Web" user-agent or an "RSS" user-agent. In the first case, you'll want to leave the URLs alone, whereas in the second case, you'll need to change them.

I'm not at all an RSS expert -- far from it. So my question is, why are these semicolons in the first place? In HTTP Web URLs, the characters used to separate query string parameters *are not* arbitrary; you *must* use ampersand. It's built into the protocol, and servers like Apache depend on it. But I'm not sure whether this is true for RSS. So, how are these characters getting "magically changed," depending on the type of user-agent fetching them from your site? That's the big mystery here...

So, I'd suggest asking about this over in the RSS forum [webmasterworld.com] before proceeding with a band-aid solution. In the meantime, have a look at some of the many other 'friendly URL' threads in this forum, and take a shot at coding a solution using mod_rewrite. In addition to RewriteRule, you'll need to use RewriteCond %{QUERY_STRING} to test and extract parameters from the query string for conversion to the proper URL format. The documents cited in our charter [webmasterworld.com] will be handy, and the charter text explains how to use this forum for best results.

Jim

BinkyM

4:33 am on Aug 7, 2005 (gmt 0)



JD:

(Been away 'cause I got good and sick, but I'm well enough to start worrying about my URLs again!)

Hokay; this is all I want to do for the time being: I want the hex ampersand in here replaced with a semi-colon:

http://example.com/cgi-bin/forums/ikonboard.cgi?act=SF%3bf=1

That's all I want: to turn "%3b" into a semi-colon. Can you help me with that?

(BTW, I believe that earlier in this thread, I was pissing and moaning about my RSS feeds being broken because the semi-colons were being replaced with ampersands, but that the pages showed up properly in Google with the semi-colons. It turns out that the program that was spitting out my RSS feed files WERE WRITING AMPERSANDS! And I seem to be the only Ikonboard user who noticed this!)

I greatly appreciate your holding my hand through these trying mod_rewrite times.