Forum Moderators: phranque

Message Too Old, No Replies

redirect 301 instead of mod rewrite: issues?

         

cla313

1:29 pm on Mar 14, 2008 (gmt 0)

10+ Year Member



Hi.

I would like to abbreviate a very long URL to another one which is much easier to distribute via email, presentations, etc.

I tried without success to abbreviate using mod_rewrite. The point is I have no control over the Apache main config file and cannot restart the service after implementing new mod_rewrite rules but have to ask every time to the sys admin. Which is not really ideal if you want to test things. After many unsuccessful attempts, I am about to give up and simply apply a permanent redirect like this:

redirect 301 /short /very/long/complicated/path

The directory /short does not physically exist (and never was). This solution not only works flawlessly but it's something I can setup myself via the .htaccess file.

I wanted to follow an approach like the one suggested here [peachpit.com...] , but why bother if I can achieve the same by the above? Well I am aware that the advantage is that you can use the rewrite map as a central administration file for all abbreviations.

I also wonder if the 301 redirect approach could negatively affect the pages ranking or there are any other search engine related issues I should be aware of. If we start to distribute the short URL via the web or use it in the website for internal links, how would this affect the real pages?
Can anyone give some advice in this matter, please?

Thanks in advance!

jdMorgan

3:36 am on Mar 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The real pages are just that -- the real pages. You --as a Webmaster-- might call them files. But search engines and browsers don't care about *anything* except URLs. On the web, the 'real' things are URLs. Only once inside the server do filepaths and filenames have any meaning.

We as Webmasters tend to think in a file-oriented way: To us a "page" is a file. But that's not true to a Web client: To a client, a "page" is a URL -- or a URL is a page.

And all is as it should be, because the fundamental job of a server is to translate Web-addresses (URLs) into server filesystem addresses (directories and filenames), so that no-one out on the Web needs to know anything about what operating system or filesystem you use, or how your files are arranged into directories, etc.

That background may make things a bit clearer, because this is how I would solve your problem.

  • Use mod_rewrite to internally map the short URL to the existing long server filepath.
    (Note that this "breaks the symmetry" between your old URL and your filepath -- They no longer resemble each other, and that's OK.)
  • Use mod_rewrite to externally 301-redirect any direct client requests for the old long URL to the new short one.
    (Note that this redirection is the revrerse of the one you propose to do.)
  • Change the links on your site to point to the new short URL.
  • Ask your major linking partners to link to the new short URL, rather than the old long one.

    You should be able to use most mod_rewrite functions in your .htaccess file, assuming that the server is configured to allow it. You can even reference (but not define) existing RewriteMaps in .htaccess if you want to.

    Jim

    [edited by: jdMorgan at 3:37 am (utc) on Mar. 15, 2008]

  • g1smd

    5:56 pm on Mar 16, 2008 (gmt 0)

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



    I use 301 redirects to create "memorable URLs" on some sites, simply to make it easier for type-in traffic to access content via a simple URL.

    You see this in action on some really big sites, such as bbc.co.uk/news and bt.com/phonebook where they redirect to the real content.