Skip to content

Instantly share code, notes, and snippets.

@makerj
Forked from fabiocicerchia/.htaccess
Created January 28, 2016 18:39
Show Gist options
  • Save makerj/00d7cf418fff2cd60600 to your computer and use it in GitHub Desktop.
Save makerj/00d7cf418fff2cd60600 to your computer and use it in GitHub Desktop.
Apache - PUT - 405 Method Not Allowed
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.+$ - [NC,L]
RewriteCond %{REQUEST_METHOD} (PUT|DELETE)
RewriteRule .* put.php
user@host:/var/www/test# apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
actions_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cache_module (shared)
cgi_module (shared)
dav_module (shared)
deflate_module (shared)
dir_module (shared)
disk_cache_module (shared)
env_module (shared)
expires_module (shared)
headers_module (shared)
mem_cache_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
ssl_module (shared)
status_module (shared)
Syntax OK
user@host:/var/www/test# curl -vX PUT -d "whatever=whatever" http://localhost/
* About to connect() to localhost port 80 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 80 (#0)
> PUT / HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost
> Accept: */*
> Content-Length: 17
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 17 out of 17 bytes
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 405 Method Not Allowed
< Date: Fri, 18 Jul 2014 06:38:18 GMT
< Server: Apache/2.2.22 (Debian)
< Allow: GET,HEAD,POST,OPTIONS
< Vary: Accept-Encoding
< Content-Length: 313
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /put.php.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at localhost Port 80</address>
</body></html>
* Closing connection #0
http://www.spinics.net/lists/apache-users/msg104136.html
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/test
LogLevel debug
<Directory /var/www/test>
Allow from all
AllowOverride All
<Limit HEAD OPTIONS GET POST PUT DELETE>
Order Allow,Deny
Allow from all
</Limit>
<LimitExcept HEAD OPTIONS GET POST PUT DELETE>
Order Deny,Allow
Deny from all
</LimitExcept>
Script PUT /var/www/test/put.php
Script DELETE /var/www/test/put.php
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment