Forum Moderators: phranque
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!
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.
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]