RewriteRule causes POST data to get dumped before I can access it
Posted
by
MatthewMcGovern
on Server Fault
See other posts from Server Fault
or by MatthewMcGovern
Published on 2012-09-28T20:04:06Z
Indexed on
2012/10/01
3:39 UTC
Read the original article
Hit count: 195
I'm currently setting up my own 'webserver' (a Ubuntu Server on some old hardware) so I can have a mess around with PHP and get some experience managing a server.
I'm using my own little MVC framework and I've hit a snag... In order for all requests to make it through the dispatcher, I am using:
<Directory /var/www/>
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(png|jpg|jpeg|bmp|gif|css|js)$ [NC]
RewriteRule . HomeProjects/index.php [L]
</Directory>
Which works great. I read on Stackoverflow to change the [L] to [P] to preserve post data. However, this causes every page to return:
Not Found
The requested URL <url> was not found on this server.
So after some more searching, I found, "Note that you need to enable the proxy module, and the proxy_http_module in the config files for this to work."
The problem is, I have no idea how to do this and everything I google has people using examples with virtual hosts and I don't know how to 'translate' that into something useful for my setup. I'm accessing my webserver via my public IP and forwarding traffic on port 80 to the web server (like I'm pretending I have a domain/server). How can I get this enabled/get post data working again?
Edit: When I use the following, the server never responds and the page loads indefinately?
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
<Directory /var/www/>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?82\.6\.150\.51/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png|jpg)$ /no-hotlink.png [L]
RewriteCond %{REQUEST_URI} !\.(png|jpg|jpeg|bmp|gif|css|js)$ [NC]
RewriteRule . HomeProjects/index.php [P]
</Directory>
© Server Fault or respective owner