重写单个目录以附加URL查询

时间:2015-08-27 17:54:58

标签: regex apache .htaccess mod-rewrite

我被困在一个网址重写上,可以通过一些专家建议。

我正在尝试将子目录重定向到一个附加传入查询的变量。

传入请求 AWSCredentialsProvider aWSCredentialsProvider = new SystemPropertiesCredentialsProvider(); //substitute the above line for any valid *Provider implementation AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(aWSCredentialsProvider); //the above line is now passing an instance of AWSCredentialsProvider //as opposed to AWSCredentials ... amazonDynamoDBClient.listTables(); //the above line is now enabled, via the AWSCredentialsProvider, to //automatically refresh the AWSCredentials if/when they have expired

期望的结果 protected void onPostExecute(String s) { if(s == null) { responseText.setText("Error en la solicitud http"); } else { try { String jsonInterpretado = ""; JSONArray jsonArray = new JSONArray(s); //jsonInterpretado = jsonArray.toString(); //jsontxt.setText(jsonInterpretado); int largoJson = jsonArray.length(); String largoArray=Integer.toString(largoJson); Log.d(TAG, "la cantidad de objetos en el array es de" + largoArray); for (int i = 0; i < jsonArray.length(); i++) { JSONObject json_object = jsonArray.getJSONObject(i); Jugadas jugadas = new Jugadas(); jugadas.setDraw_date(json_object.optString("draw_date")); //Log.d(TAG, "draw date" + i + jugadas.getDraw_date()); jugadas.setWinnin_numbers(json_object.optString("winning_numbers")); jugadas.setMultiplier(json_object.optString("multiplier")); arrayOfData.add(jugadas); /* String drawdate = json_object.optString("draw_date"); String numbers = json_object.optString("winning_numbers"); String multiplier = json_object.optString("multiplier");*/ } responseText.setText("Conexion OK"); lv.setAdapter(adapter); //Log.d(TAG, arrayOfData.toString()); } catch (Exception e) { e.printStackTrace(); } } }

每次我希望只将该目录作为变量附加到URL时,/ qwerty /目录名称将根据传入请求而改变。

1 个答案:

答案 0 :(得分:1)

您可以在DOCUMENT_ROOT/.htaccess文件中使用此规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(guest/d)/([^/]+)/$ /$1/?dir=$2 [L,NC,QSA,R=302]