Sunday, February 08, 2015

apache rewrite testi

apache htaccess veya httpd confa yazdığımız rewrite ları test etmek zordur. browser ın cache indemi kaldı. loadbalancer danmı döndü anlamak için ctrl f5 lere basılı tutulur incognito ile denenir. ama curl varken bunlara gerek yok.

ben user agent a göre bir rewrite yazmıştım. mobile redirect işlemi için. curl ilede şöyle test ettim

curl -A "curl" --head --header "Host: domain.com" http://127.0.0.1/

bu komutta A parametresinin arkasından user agent geliyor. ve apache de 127.0.0.1 de çalıştığı için oraya domain.com u istiyorum. gördüğüm sonuç şöyle

HTTP/1.1 200 OK
Date: Sun, 08 Feb 2015 09:45:21 GMT
Server: mascix
Cache-Control: max-age=0, no-cache, proxy-revalidate
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8

buda zaten istediğim gibi curl user agent ı zaten ilgi alanıma girmediği için redirect etmiyor. ama mobil bir user agent ile istek yapılırsa nolur.

curl -A "MOBILE" --head --header "Host: ipmap.info" http://127.0.0.1/

dönen cevap şöyle:

HTTP/1.1 301 Moved Permanently
Date: Sun, 08 Feb 2015 09:49:06 GMT
Server: mascix
Location: http://m.domain.com/
Cache-Control: max-age=900
Expires: Sun, 08 Feb 2015 10:04:06 GMT
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

yani server 301 redirect verdi ve m.domain.com a gitmem gerektiğini söyledi. bu sayede redirectin düzgün çalıştığını test etmiş oldum.

No comments:

odd string diff

 https://leetcode.com/problems/odd-string-difference/ Beats 19.92% of users with Java   class Solution { public String oddString ( S...