Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a rewrite rule that works fine, but the reason why we're rewriting is because the target URL is not so tidy.

foo.com/bar -> foo.com/some/really/long/address

What I would like to do is keep the foo.com/bar URL in the browser, but show the foo.com/some/really/long/address page. Is this possible?

share|improve this question
Yes, it's possible. Show your rewrite rules. –  joschi Jul 4 '10 at 13:28

1 Answer 1

mod_rewrite it what you need.

This is quite easy and its a powerfull tool.

I suggest to read this -> http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

And example :

this estarts de rewriteengine, then applies some conditions and if they are true then applies the rewrite itself. its like a while/case codeblock.

The most helpful part is the log .;)

    RewriteEngine on
RewriteLogLevel 0
RewriteLog "/var/www/rewrite.log"

<Directory /var/www>

    Options -ExecCGI -Indexes
    AllowOverride none
    Order allow,deny
    allow from all
    #SetHandler none

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(\w+.\w+)/(es|ca|en)/$ index.php?user=$1&lang=$2 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(\w+.\w+)/$ index.php?user=$1&lang= [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(\w+.\w+)/(\w+)?(/(.*))?$ index.php?user=$1&lang=$2$4 [L,QSA]

also, you can look at mod_proxy, it will do the trick but it's not the 'good way' in my opinion.

hope it helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.