2

我正在寻找正确的.htaccess规则来制作 Facebook.com/user URL,例如

例如,如果我访问我想要什么

www.domain.com/StackOverFlow

它将被重写为

www.domain.com/index.php?category=StackOverFlow

或者

www.domain.com/category.php?item=StackOverFlow

有什么帮助吗?我在这里尝试了一些问题,但他们没有明确地这样做。

提前致谢

编辑:

忘了说我只想使用此规则进行重定向,域之后的任何内容都没有任何扩展名

例如它应该重定向www.domain.com/categoryDescription但没有www.domain.com/categoryDescription.phpwww.domain.com/categoryDescription.html

4

3 回答 3

3

下面的示例采用 URI.com/并将其分配给$1. 你可以对“项目”做同样的事情

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?category=$1 [L]
于 2012-06-21T20:22:18.870 回答
3
<IfModule mod_rewrite.c>
  RewriteEngine on
  # Rewrite URLs of the form 'x' to the form 'index.php?category=x'.
  RewriteRule ^(.*)$ index.php?category=$1 [L,QSA]
</IfModule>
于 2012-06-21T20:24:41.567 回答
3

尝试:

RewriteRule ^StackOverFlow$ index.php?category=StackOverFlow [NC,L]

或者:

 RewriteRule ^StackOverFlow$ category.php?item=StackOverFlow [NC,L]

大体上:

RewriteRule ^([^/]*)$ index.php?category=$1 [NC,L]

或者:

 RewriteRule ^([^/]*)$ category.php?item=$1 [NC,L]
于 2012-06-21T20:19:47.823 回答