htaccess的短期和友好的URL [英] .htaccess short and friendly url
问题描述
我在寻找合适的的.htaccess
规则做出Facebook.com/user URL如
I'm looking for the right .htaccess
rule to make a Facebook.com/user URL like
我想如果我访问例如:
www.domain.com/StackOverFlow
这将是改写为
It will be rewrite to
www.domain.com/index.php?category=StackOverFlow
或
www.domain.com/category.php?item=StackOverFlow
任何帮助吗?我已经尝试了一些问题,在这里,但他们并没有明确的做这种行为。
Any help? I've tried some question here, but they doesn't explicit do this behavior.
在此先感谢
编辑:
忘了说了,我只是想利用这条规则被重定向,任何域名之后,没有任何扩展
Forgot to say that I only want to be redirected using this rule, anything that after the domain, doesn't have any extension
例如它应该重定向 www.domain.com/categoryDescription
,但没有 www.domain.com/categoryDescription.php
或 www.domain.com/categoryDescription.html
For example it should redirect www.domain.com/categoryDescription
but no www.domain.com/categoryDescription.php
or www.domain.com/categoryDescription.html
推荐答案
下面的例子发生在URI后 .COM /
和分配,为 $ 1
。
您可以为项目
The example below takes the URI after .com/
and assigns that to $1
.
You can do the same for "item"
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?category=$1 [L]
这篇关于htaccess的短期和友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!