2011-08-09 3 views
0

도메인이 두 개 있습니다. mydomain.commydomain.org입니다. 사이트가 mydomain.org에 있으므로 mydomain.com을 시도하여 mydomain.org으로 해결하려고합니다.mod_rewrite 조건 및 규칙 효과 POST vars가 잘못되었습니다.

학위를 준수하는 다음 mod_rewrite 규칙.

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^mydomain\.com$ 
RewriteRule^http://mydomain.org%{REQUEST_URI} [L,R=301] 

나는 그것을 구현하고 테스트 한 후에 method = "post"를 사용하여 양식을 제출할 때까지 필요한 모든 작업을 수행하고 있다고 느꼈습니다. 어떤 이유

이 mod_rewrite를 내 _POST 내가 mydomain.org에서 유일하고 있어요

을 바르 (나는에서 해결하기 위해 사이트를 원하는 TLD 인 내가에서 양식을 제출 한 경우) 삭제 한 사용자.

누구나 내 상태와 규칙을 조정하여 _POST 값을 잃지 않는 것을 알고 있습니까?


나는 흥미로운 것을 발견했다. Firefox에 HTTP 라이브 헤더 애드온을 연결했습니다. 내가 mod_rewrite를 사용할 때 "HTTP/1.1 404 Not Found"가 나타나고 mod_rewrite를 끄면 "HTTP/1.1 200 OK"가 표시됩니다. 동일한 페이지와 PHP 코드가 사용됩니다. 다시 말하지만 mod_rewrite 지시문을 끄면 _POST 데이터가 전달됩니다. mod_rewrite 지정 문을 켜면 _POST 데이터가 전달되지 않습니다.

mod_rewrite를 꺼진 :

http://dashausmuseum.org/subscribe.html 

POST /subscribe.html HTTP/1.1 
Host: dashausmuseum.org 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Referer: http://dashausmuseum.org/subscribe.html 
Cookie: __utma=74430599.461726749.1312575846.1312897084.1312899646.5; __utmz=74430599.1312575846.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=1.480711209.1312899756.1312979975.1312981669.5; __utmz=1.1312981669.5.5.utmcsr=dashausmuseum.com|utmccn=(referral)|utmcmd=referral|utmcct=/directions.html; __utmb=1.9.10.1312981669; PHPSESSID=7f4a74d7fde56cf901aa85511410b7f6; __utmc=1 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 60 
email=abc&firstName=&lastName=&address=&phone=&submit=Submit 

HTTP/1.1 200 OK 
Date: Wed, 10 Aug 2011 13:18:31 GMT 
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.3.4 
X-Powered-By: PHP/5.3.4 
Expires: Thu, 19 Nov 1981 08:52:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
Pragma: no-cache 
Content-Length: 5420 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Content-Type: text/html 

mod_rewrite를 켜진 :

http://dashausmuseum.org/subscribe.html 

POST /subscribe.html HTTP/1.1 
Host: dashausmuseum.org 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Referer: http://dashausmuseum.org/subscribe.html 
Cookie: __utma=74430599.461726749.1312575846.1312897084.1312899646.5; __utmz=74430599.1312575846.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=1.480711209.1312899756.1312979975.1312981669.5; __utmz=1.1312981669.5.5.utmcsr=dashausmuseum.com|utmccn=(referral)|utmcmd=referral|utmcct=/directions.html; __utmb=1.10.10.1312981669; PHPSESSID=7f4a74d7fde56cf901aa85511410b7f6; __utmc=1 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 60 
email=xyz&firstName=&lastName=&address=&phone=&submit=Submit 

HTTP/1.1 404 Not Found 
Date: Wed, 10 Aug 2011 13:20:32 GMT 
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.3.4 
X-Powered-By: PHP/5.3.4 
Expires: Thu, 19 Nov 1981 08:52:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
Pragma: no-cache 
Content-Length: 5329 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Content-Type: text/html 

사람이 무슨 일이 일어나고 있는지에 대한 단서를 제공하는 HTTP 헤더에 아무것도 볼 수 있습니까?

+0

문법적으로 올바르지 않은 3 가지 지시어에 대해 아무도 볼 수 없습니까? –

답변

0

뭔가 다른 것이 틀림 없습니다. 다시 쓰기 규칙은 _POST 변수를 파괴 할 수 없습니다.

어떻게 코드에서 설정/호출하고 있습니까?

+0

PHP를 코드로 사용하고 있습니다 ($ _POST [ 'element'] 등으로 참조하고 있습니다). 그러나 흥미로운 점은 내 .htaccess 파일에서 3 개의 mod_rewrite 행을 주석 처리 (#)하면 양식이 POST 데이터와 함께 제출된다는 것입니다. 그러나 3 개 지시문의 주석을 제거하는 순간 양식은 제출하지 않고 POST 데이터를 제출합니다. –

+0

Google 검색을 통해 여러 가지 유사한 문제를 발견했습니다. 그래서 문제가되는 것 같습니다. _POST 데이터에서 _GET 데이터로 모든 것을 변경했지만 여전히 작동하지 않습니다. –

+0

양식이 http://domain.org/form.html에서 http://domain.com/action.php를 호출하는 경우 도메인 간 보안 문제 일 수 있습니다. .org/form.html에서 .org/action.php를 호출 할 때 이런 현상이 발생합니까? – red

0

301 (또는 기타) 리디렉션에 대한 응답으로 POST 트랜잭션에 어떤 일이 일어나야하는지에 대한 몇 가지 논의가 있습니다. Here is one example 저자는 "지저분한"것이라고 제안합니다.

브라우저가 POST를 GET 요청으로 변환 할 수 있습니까? 다른 브라우저에서도 동작이 다를 수 있습니까?

+0

나는 _POST와 FF5, IE8, Opera11, Safari5 및 Chrome에서 _GET을 사용합니다. 어떤 언어로도 작동하지 않았습니다. –

+0

필자는 링크 된 글에서 테이크 어웨이를 제공하고 참조 (RFCs 등)를 읽은 일부는 다음과 같습니다. POST 요청에 대한 리다이렉트 응답을 보내면, 브라우저를 통해 옳은 일을 할 수 있으며, 옳은 일은 어쨌든 당신이 원하는 행동 일 것입니다. "HTTP 사양은 클라이언트가 자동으로 리디렉션 된 트랜잭션." – bmb