用apache htaccess清理网址

时间:2015-04-25 17:45:45

标签: apache .htaccess

如何转换此网址

namespace Diner
{
    public class Order
    {
        public string[] menuEntree = new
            string[] {"Chicken Salad",
                        "Ham and Cheese",
                        "Turkey",
                        "Vegetable Wrap",
                        "Tuna Salad",
                        "Avocado and Cheese",
                        "Club",
                        "Peanut Butter & Jelly",
                        "Cheese Toasty",
                        "Reuben"};
        public decimal[] menuEntreePrice = new
            decimal[] {4.50m,
                        5.00m,
                        4.75m,
                        4.00m,
                        4.50m,
                        4.00m,
                        5.50m,
                        3.75m,
                        3.50m,
                        5.00m};

        private string entree;
        private bool waterSelection;
        private string drinkSelection;
        private string specialRequest;
        private decimal entreePrice;
        private decimal drinkPrice;

        // Default Constructor
        public Order()
        {
            entree = "";
            waterSelection = false;
            specialRequest = "";
            drinkPrice = 0;
            entreePrice = 0;
        }

        //Property for Entree
        public string Entree
        {
            get
            {
                return entree;
            }
            set
            {
                entree = value;
                SetEntreePrice();
            }
        }

        // Property for special request
        public string SpecialRequest
        {
            get
            {
                return specialRequest;
            }
            set
            {
                specialRequest = value;
            }
        }
        // Property for Water Selection
        public bool WaterSelection
        {
            set
            {
                waterSelection = value;
            }
        }

        // Property for Drink Selection
        public string DrinkSelection
        {
            get
            {
                return drinkSelection;
            }
            set
            {
                drinkSelection = value;
                SetDrinkPrice();
            }
        }

        // Read-only property for entreee price
        public decimal EntreePrice
        {
            get
            {
                return entreePrice;
            }
        }

        // Read-only property for drink price
        public decimal DrinkPrice
        {
            get
            {
                return drinkPrice;
            }
        }

        // After the entree is set, store the entree price
        public void SetEntreePrice()
        {
            for (int i = 0; i < menuEntree.Length; i++)
            {
                if (menuEntree[i] == entree)
                {
                    entreePrice = menuEntreePrice[i];
                }
            }
        }

        // Return the water selection
        public string GetWaterSelection()
        {
            string waterOrNot;

            if (waterSelection)
            {
                waterOrNot = "Water";
            }
            else
            {
                waterOrNot = "No Water";
            }
            return waterOrNot;
        }

        // After the drink is set, store the drink price
        public void SetDrinkPrice()
        {
            switch (drinkSelection)
            {
                case "Tea":
                case "Coffee":
                    drinkPrice = 1.50m;
                    break;
                case "Soda":
                case "Lemonade":
                    drinkPrice = 2.00m;
                    break;
                case "Milk":
                case "Juice":
                    drinkPrice = 1.75m;
                    break;
            }
        }

        // return the total cost of the order
        public decimal DetermineTotalCharges()
        {
            return entreePrice + drinkPrice;
        }

        public override string ToString()
        {
            return "Toatal Due: " + DetermineTotalCharges().ToString("C");
        }
    }
}

像这样干净

 http://example.com/vpage/page.php?number=1&status=completed 

这样在我的php页面中我可以回显变量1并完成。

由于

1 个答案:

答案 0 :(得分:0)

在你的root / .htaccess

中试试这个
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)/([a-zA-Z0]+)/?$ /vpage/page.php?number=$1&status=$2 [QSA,NC,L]