htaccess - 在保持查询字符串结束的同时重写规则

时间:2015-08-04 03:23:33

标签: apache .htaccess mod-rewrite

我试图实现包含查询字符串

的部分重写规则

我想要以下网址:

/cart.php?a=add&pid=1     // with "1" being a dynamic integer

是:

/checkout?pid=1    // with "1" being the dynamic corresponding integer

我尝试了以下但是它不适合我。任何帮助将不胜感激。提前谢谢!!

RewriteCond %{QUERY_STRING}  ^pid=(.*)$
RewriteRule ^checkout$ ./cart.php?a=add&pid=%1 [R=301,L]

1 个答案:

答案 0 :(得分:0)

您只需设置QSA(查询字符串追加)标记,以保留原始字符串,例如。

public class MainActivity extends Activity {



    Context context;
   protected void onCreate(Bundle savedInstanceState)
    { super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //geschw=(TextView) findViewById(R.id.Geschwindigkeit);

        LocationManager locationManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE);



        LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) {

            location.getLatitude();
            Context neu = MainActivity.this;

            try {

                Toast.makeText(neu, "Current speed:" + location.getSpeed(), Toast.LENGTH_SHORT).show();
            }
            catch (NullPointerException e){}
        }


            public void onStatusChanged(String provider, int status, Bundle extras) { }

            public void onProviderEnabled(String provider) { }

            public void onProviderDisabled(String provider) { }
        };

        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
    }
}