-1

Ok I'm pulling my hair out, can't get the mod_rewrite rules to work.

This is my apache config

<VirtualHost x.x.x.x:80>
DocumentRoot "/web/domain1/"
ServerName www.example.com
ServerAlias example.com

        <Directory "/web/domain1/">
        Options -Indexes
        </Directory>
</VirtualHost>

My directory layout

/web
    |
    --domain1/ (/web/domain1)
    |
    ------report/ (/web/domain1/report)
    |
    -----------public/ (/web/domain1/report/public)

I'm trying to put a rewrite rule into the apache config such that when a user accesses www.domain1.com/report they get served from the /web/domain1/report/public folder, and the URL should remain as www.domain1.com/report. Appreciate any help.

2
  • can you clarify more?I am lil confused,your mod_rewrite is working but you are not able to get it working according to specification in your question right?or the mod_rewrite is not working at all? Jul 8, 2014 at 8:34
  • mod_rewrite works. I can't create the correct rules to get what I want done.
    – d123
    Jul 8, 2014 at 8:37

1 Answer 1

0

To redirect just a subdirectory of the server, you can use mod_rewrite like this:

RewriteCond %{REQUEST_URI} /url [NC]
RewriteRule ^(.*)$ other.example.com/$1 [R]

And if your trying to show the content of the other site without the user seeing the other url, you'll need both mod_rewrite and mod_proxy like this:

RewriteCond %{REQUEST_URI} /url [NC]
RewriteRule ^(.*)$ http://other.example.com/$1 [P]

Other configuration steps may be necessary for mod_proxy, depending on your environment.

Also consider Apache's Advanced mod_rewrite Guide.

1
  • this does not answer my question.
    – d123
    Jul 8, 2014 at 8:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .