我是Yii的新手,我在创建Yii SEO Friendly网址时面临一些困难。
我的代码如下:
import java.util.Scanner;
public class MovieFee {
public static void main(String[] args)
{
//scanner class
Scanner input=new Scanner(System.in);
//declare fee variables
double movieFee = 0.0;
double snackFee = 0.0;
double couponFee = 0.0;
do {
//display the age options and prompt the user to enter one
System.out.println("Child (<12)");
System.out.println("Adult (12-65)");
System.out.println("Senior (>65)");
System.out.print("Choose your age category: ");
String age=input.nextLine();
//calculate the movie fee
if(age.equalsIgnoreCase("child"))
{
movieFee=5.50;
}
else if(age.equalsIgnoreCase("adult"))
{
movieFee=8.50;
}
else if(age.equalsIgnoreCase("senior"))
{
movieFee=6.00;
}
else
{
System.out.println("\nYou did not enter a correct age group.");
System.out.println("Please try again using one of: child, adult, senior\n");
}
} while(movieFee==0.0);
do {
//display the snak bar options and prompt the user to enter one
System.out.println("\nA - popcorn and pop");
System.out.println("B - chocolate bar and pop");
System.out.println("C - popcorn and candy and pop");
System.out.print("What is your snack bar option(enter a letter): ");
String snackOption=input.nextLine();
//calculate the snack fee
if(snackOption.equalsIgnoreCase("a"))
{
snackFee=7.90;
}
else if(snackOption.equalsIgnoreCase("b"))
{
snackFee=6.30;
}
else if(snackOption.equalsIgnoreCase("c"))
{
snackFee=8.90;
}
else
{
System.out.println("\nYou did not enter a correct option");
System.out.println("Please try again using either A, B or C");
}
} while (snackFee==0.0);
String coupon="";
do {
//ask the user if he/she has a coupon
System.out.print("\nDo you have a coupon? Type yes or no: ");
coupon=input.nextLine();
if(coupon.equalsIgnoreCase("yes"))
{
couponFee=2.0;
}
else if(coupon.equalsIgnoreCase("no"))
{
couponFee=0;
}
} while (!coupon.equalsIgnoreCase("yes") && !coupon.equalsIgnoreCase("no"));
//calculate the total fee and total fee
double result = movieFee + snackFee + couponFee;
System.out.println("Final price is "+result);
}
//end main
}
//end class
此解决方案位于config / main:
下面echo CHtml::link($Menu->label, array('articles/view', 'id'=>$Menu->link,
但是这个项目创建了另一个URL,如下所示:
return array(
// ......
'components'=>array(
// ......
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'articles/<id:\d+>-<t:.+>'=>'articles/view',
// .......
),
),
),
);
如何在此类链接上创建SEO友好网址。
综述
相同的项目创建两个类型的SEO友好URL
谢谢
答案 0 :(得分:0)
试试这个,
"articles/view/<id:([a-zA-Z0-9$&,':=?|.^*()%~!-]+)>" => "articles/view",
并将网址称为/ articles / view / id / 1