php htaccess重写帮助我

php htaccess重写帮助我,php,.htaccess,variables,get,rewrite,Php,.htaccess,Variables,Get,Rewrite,在那里。 我是htaccess的新手。 请帮我2写url重写这些链接 网址: url-index.php?page=news url-index.php?页面=用户&昵称=名称 url-index.php?cat=Category url-index.php?cat=Category&seo-link=Title url-index.php?cat=Category&sub_cat=SubCategory url-index.php?cat=Category&sub_cat=SubCatego

在那里。 我是htaccess的新手。 请帮我2写url重写这些链接

网址:

  • url-index.php?page=news
  • url-index.php?页面=用户&昵称=名称
  • url-index.php?cat=Category
  • url-index.php?cat=Category&seo-link=Title
  • url-index.php?cat=Category&sub_cat=SubCategory
  • url-index.php?cat=Category&sub_cat=SubCategory&seo link=Title
  • url-index.php?page=gallery&album=albumName
  • url-index.php?page=gallery&album=albumName&image=imageName
需要是Url的:

  • page.com/news/
  • page.com/user/昵称/
  • page.com/it-news/
  • page.com/it-news/old/title/
  • page.com/it-news/title/
差不多吧。 谢谢,非常感谢

一个例子

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^news/?$    index.php?cat=news    [NC,L]
请注意!您在Apache上的modRewrite大多数处于活动状态
您可以进一步读取主目录中的文件并将此代码放入其中。调用文件
.htaccess

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^([A-Za-z0-9_-]+)/?([A-Za-z0-9_-]+)?/?$    index.php?cat=$1&page=$2    [NC,L]
带数字和字母的括号是允许的,括号中的内容将转到cat=where
$1
是url中的变量。第二个括号将指向
$2
所在的位置。例如,如果您在浏览器中键入
/it news
,它实际上会加载
index.php?cat=it news&page=
,如果您键入
/it news/datahere
,它实际上会加载
index.php?cta=it news&page=datahere
。每一个?在代码中,意味着它之前存在的东西不需要存在,也不需要存在一次或多次。()是按$1$2$3顺序的回调


希望这有帮助

这只涵盖了他需要的一条规则。这对我来说不起作用:(当你尝试它时会发生什么?我写错了,一秒钟,再看看我的代码,对不起,谢谢你帮助我:)我在这里帮助其他人:p随时:)