Get Content of the http request

Using mod_rewrite to handle various content issues

Get Content of the http request

Postby SelvamS » Mon Aug 25, 2008 3:54 am

Hi,

I am trying to get the content type of the request and do change the rewrite pattern. I could not get the content type of the request with the following code:

[i]RewriteEngine On
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} ^(.*)First.html$
RewriteCond %{HTTP:Content-Type} ^(.*)text/text(.*)$
RewriteRule ^/myapp/First.html$ /myapp/Second.html [/i]

Here is my HTML code

[i]<HTML>
<HEAD>
<meta content="text/html;" http-equiv="Content-Type">
</HEAD>
<BODY>
<H5> First Page </H5>
</BODY>
</HTML>[/i]

Can anybody help me to get the content type from the request object?

Thanks a lot

Regards
Selvam S
SelvamS
 
Posts: 2
Joined: Mon Aug 25, 2008 3:46 am

Postby richardk » Tue Aug 26, 2008 10:46 am

Mod_rewrite works on the HTTP request. The Content-Type header is part of the response. You cannot get the Content-Type with mod_rewrite. Also, <meta> tag does not set a HTTP response header.

What are you trying to achieve?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Get Content of the http request

Postby SelvamS » Tue Aug 26, 2008 7:04 pm

I am working on a task, which involves rewriting request to two different URLs based on the type of request.

For e.g If the request comes in SOAP1.1 (content-type=text/xml) format it should be directed to one URL, if SOAP1.2 (content-type=application/soap+xml) it should be directed to a different one. I would like to if this is possible by reading the request's content type. Please let me know if there is anyother possible solution to achieve this.

Thanks
SelvamS
 
Posts: 2
Joined: Mon Aug 25, 2008 3:46 am

Postby richardk » Fri Aug 29, 2008 10:30 am

Do you know if there is anything different about the HTTP headers sent when making the requests?

You can try matching the Accept header, if it is sent
Code: Select all
Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_ACCEPT} ^(.*,\ )?application/soap+xml(,\ .*)?$ [NC]
RewriteRule ^/myapp/First\.html$ /should-work-with-1.2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 10 guests

cron