need to abbreviate URL using mod rewrite

Discussion in 'Apache' started by apachenoob, May 21, 2008.

  1. #1
    Hello

    I'm trying to use mod rewrite to abbreviate a long URL to a shorter one so that when users use the shorter URL, it takes them to the long URL.ex) domain.com/cie > domain.com/Computers_and_Internet_Economy

    The apache config file already has some rewrite rules since the software installed came with it as below:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^/$ /index.php?title= [L,NE]

    RewriteCond %{REQUEST_URI} ^/@gui/[^.]+$
    RewriteRule ^/@gui/(.*)$ /proxy.php?path=$1 [L,QSA,NE]

    RewriteCond %{REQUEST_URI} !^/(@api|editor|skins|config|@gui)/
    RewriteCond %{REQUEST_URI} !^/index\.php
    RewriteCond %{REQUEST_URI} !^/favicon\.ico$
    RewriteCond %{REQUEST_URI} !^/robots\.txt$
    RewriteCond %{QUERY_STRING} ^$ [OR] %{REQUEST_URI} ^/Special:Search
    RewriteRule ^/(.*)$ /index.php?title=$1 [L,QSA,NE]

    So I've added the line
    "RewriteRule ^/cie ^/Computers_and_Internet_Economy" to the apache config file as below:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^/$ /index.php?title= [L,NE]

    RewriteCond %{REQUEST_URI} ^/@gui/[^.]+$
    RewriteRule ^/@gui/(.*)$ /proxy.php?path=$1 [L,QSA,NE]

    RewriteCond %{REQUEST_URI} !^/(@api|editor|skins|config|@gui)/
    RewriteCond %{REQUEST_URI} !^/index\.php
    RewriteCond %{REQUEST_URI} !^/favicon\.ico$
    RewriteCond %{REQUEST_URI} !^/robots\.txt$
    RewriteCond %{QUERY_STRING} ^$ [OR] %{REQUEST_URI} ^/Special:Search
    RewriteRule ^/(.*)$ /index.php?title=$1 [L,QSA,NE]
    RewriteRule ^/cie ^/Computers_and_Internet_Economy

    But it doesn't work.
    I'm not familiar with mod_rewrite so if you could assist, I'd appreciate it.

    Thanks.
     
    apachenoob, May 21, 2008 IP