Mod_rewrite and dynamic content based on HTTP:Accept

Mod_rewrite and dynamic content based on HTTP:Accept

Post by David La Croi » Fri, 11 Aug 2000 04:00:00



I think I'm beginning to lose my mind.

I want to deliver different home pages (replace index.html) based on
the contents of %{HTTP-ACCEPT} ... basically as follows:

if HTTP-ACCEPT matches /wml/  (perl regular expression), I
want to redirect the user to index.wml

if HTTP-ACCEPT matches /hdml/  (perl regular expression), I
want to redirect the user to index.hdml

Otherwise, they get index.html

I can't figure out why the following doesn't work:

Rewri*gine on
RewriteCond %{ENV:HTTP-ACCEPT} wml
RewriteRule ^/index\.html$     index.wml      
RewriteCond %{ENV:HTTP-ACCEPT} hdml
RewriteRule ^/index\.html$     index.hdml

I've tried everything from JUST

Rewri*gine on
RewriteRule ^/$ index.wml

To including just about every flag possible

and STILL nothing happens.  Can anybody tell me what's wrong?

Apache 1.3.12 + mod_php4 + mod_perl + mod_ssl on FreeBSD 3.5

--

 
 
 

Mod_rewrite and dynamic content based on HTTP:Accept

Post by David La Croi » Sat, 12 Aug 2000 04:00:00


I know it's usually bad form to follow up to one's own post, but
I figured I'd post the info here for anyone who might be searching.


Quote:> I want to deliver different home pages (replace index.html) based on
> the contents of %{HTTP-ACCEPT} ... basically as follows:
> if HTTP-ACCEPT matches /wml/  (perl regular expression), I
> want to redirect the user to index.wml
> if HTTP-ACCEPT matches /hdml/  (perl regular expression), I
> want to redirect the user to index.hdml
> Otherwise, they get index.html
> I can't figure out why the following doesn't work:
> Rewri*gine on
> RewriteCond %{ENV:HTTP-ACCEPT} wml
> RewriteRule ^/index\.html$     index.wml      
> RewriteCond %{ENV:HTTP-ACCEPT} hdml
> RewriteRule ^/index\.html$     index.hdml

the CORRECT lines to do this look like:

Rewri*gine on
RewriteCond %{HTTP_ACCEPT} wml
RewriteRule ^$  index.wml
RewriteCond %{HTTP_ACCEPT} hdml
RewriteRule ^$  index.hdml  

I was making 2 mistakes:   1: it's HTTP_ACCEPT; NOT HTTP-ACCEPT
                           2: the rules are based on relative from root,
                                so ^$ matches /

--


 
 
 

Mod_rewrite and dynamic content based on HTTP:Accept

Post by jdai.. » Wed, 16 Aug 2000 04:00:00


When I try going to an html page in my browser it gives me an access
forbidden 403 error.  When I take out the [T=application...] part, it
just prints the cgi file contents to the screen.  All my cgi script
does right now is print a character and if I go directly to the cgi
script in my browser it works fine.  How can I tell apache to RUN the
script rather than PRINT the script?  Thanks.

Rewri*gine  on
RewriteRule  .html$  /cgi-bin/page.cgi [T=application/x-httpd-cgi]

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

Mod_rewrite and dynamic content based on HTTP:Accept

Post by Joshua Sliv » Wed, 16 Aug 2000 04:00:00



> When I try going to an html page in my browser it gives me an access
> forbidden 403 error.  When I take out the [T=application...] part, it
> just prints the cgi file contents to the screen.  All my cgi script
> does right now is print a character and if I go directly to the cgi
> script in my browser it works fine.  How can I tell apache to RUN the
> script rather than PRINT the script?  Thanks.
> Rewri*gine  on
> RewriteRule  .html$  /cgi-bin/page.cgi [T=application/x-httpd-cgi]

You'll need to have "Options +ExecCGI" specified for that directory.

By the way, you should start a new thread when you have a new
question, rather than just replying to an existing thread and
changing the subject.  Otherwise, threaded newsreaders will
dump your message under the one you are replying to.

--
Joshua Slive

http://www.veryComputer.com/~slive/

 
 
 

1. filtering content based on dynamic IP / proxy-firewalls

Hello,

Our company is looking to licence/buy a proxy-firewall server
that can allow specific IP addresses, using the proxy, to access only
specific
URLs. We want to be able to configure what IP addresses can access
which
URLs by simply modifying a file or commandline, and the changes should
take effect immediately. This file or commandline would ideally be in
the
format of : ip has access to URLs, in a table. This configuration
should
also be dynamic because one day user A might be 203.23.4.2 and the
next the
might have a totally different IP. So we want to be able to add or
remove
configuration entries dynamically (this will be done from our
programs)
and have the changes take effect immediately.

For example allowing user (A) with IP: 203.23.4.2 to only access
www.microsoft.com and
www,cisco.com, And the next day the same user A with a different IP
(because it
is dynamically allocated) the same restrictions or possibly different
restrictions
depending on the input from our program into the proxy config.

We cannot perform the configuration through a GUI, because we
are automating the process through a program.

We are preferably looking at a windows solution, but if the UN*X one
is
easier and more efficient we will look to un*x.

Anyone know of a nice solution ?

Thanks for your time,
Mate

2. Help - can't read backup-dat

3. mod_rewrite: https ---> https (to correct ssl vhost)

4. adaptec on a 8 bit transfer mode

5. Virtualhost accepting both http and https

6. force carriage return in man-page?

7. Apache/1.2.5+SSleay: HTTPS vars not available to mod_rewrite?

8. MH --> Maildir

9. Can mod_rewrite add new HTTP headers?

10. mod_rewrite and the HTTP REFRESH directive

11. mod_rewrite to convert dynamic JSP URL to static?

12. Dynamic Mirror and mod_rewrite

13. how to disable Solaris accept ISP dynamic hostname ??