繁体   English   中英

.htaccess短而友好的网址

[英].htaccess short and friendly url

我正在寻找合适的.htaccess规则来制作Facebook.com/user网址

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

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

尝试:

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]

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

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?category=$1 [L]
<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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM