Forum Moderators: phranque

Message Too Old, No Replies

Redirects for articles in print media

The problem with the point at the end of the URL

         

jetteroheller

4:45 pm on Oct 5, 2006 (gmt 0)

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



I have just placed an article in a print media.

At the end is my URL

The full test is to read at www.example.com/article.

I just checked my log files, already around 10 people wrote as URL

www.example.com/article.

So when placing an article in a print media, it's a good idea to create some redirects like

RedirectPermanent /article. http://example.com/article/index.htm
RedirectPermanent /article, http://example.com/article/index.htm

This is print media user secure .htaceess design

Lipik

12:17 pm on Oct 6, 2006 (gmt 0)

10+ Year Member



very good advice!
I see this often in my newspaper (printed and web-version).

Thanks

jdMorgan

3:39 pm on Oct 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's possible that many punctuation characters might follow a URL in print, for example, a comma, exclamation point, or closing parenthese, or that such trailing characters might be present because of bad HTML markup. If you have permission to use mod_rewrite, something like the following .htaccess code example can be used to remove any non-alphanumeric characters following a URL or appended to a query string:

# Remove trailing punctuation for printed-text links (Remove any trailing
# hex-encoded characters or any characters not one of a-z, A-Z, or 0-9)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)(\%(25)*[0-9a-f]{2}¦[^a-z0-9])\ HTTP/[0-9]+\.[0-9]$ [NC]
RewriteRule . http://%{HTTP_HOST}/%1 [R=301,L]

This works as described in the comments, and care should be taken to modify it before use if your site uses URLs or query strings ending in non-alphanumeric characters. Note that trailing multiply-encoded characters (e.g %25252c) are also removed.

Replace the broken pipe "¦" character in the code above with a solid pipe character before use; Posting on this forum modifies the pipe characters.

Jim