Re: [users@httpd] Re: mod_rewrite Scenario Assistance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/1/06, Rob Wilkerson <r.d.wilkerson@xxxxxxxxx> wrote:
I've gotten some great feedback on this question, but would still
really like to see some kind of example code to help me get started.
I suspect I'll need to use RewriteBase and RewriteCond in addition to
RewriteRule, but I'm not feeling all that confident in my, ahem,
analysis.

In my case, for any given virtual host, I need everything to go to
landingpage.php *except* for requests to anything in /se or anything
in /bfg (both are aliases - Alias /se /opt/product/version/se).  Can
anyone throw together some simple directives to show me how I might
accomplish this?  I also need to pass along the original URL, but I
imagine I can work that out if I understand the first part well
enough.  The rewrite itself is where I think I'm most lost.

You don't need RewriteBase unless you are using .htaccess files.  You
can also avoid RewriteConf for a simple scenario like this:

RewriteEngine On
RewriteRule ^/bfg - [L]
RewriteRule ^/se - [L]
RewriteRule ^/landingpage.php - [L]
RewriteRule ^/(.*) /landingpage.php?$1

The first three rules are rewrite a path back to itself and then end
processing.  The last RewriteRule does the real work.  I passed the
original path in the query string, but it could also be passed as
PATH_INFO or just fished out of the environment.  (Try dumping the
entire environment in you landingpage.php and you should be able to
pick out the original path someplace.)  Use the RewriteLog to debug.

I suspect you also have another requirement that you didn't mention:
the internal redirect to the landing page should happen only for
requests that do not have local referers.  If so, you need to add
RewriteCond %{HTTP_REFERER} !^http://mysite.com/ [NC]
before the final RewriteRule.

Joshua.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux