htaccess的短期和友好的URL [英] .htaccess short and friendly url

查看:122
本文介绍了htaccess的短期和友好的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/categoryDe​​scription ,但没有 www.domain.com/categoryDe​​scription.php www.domain.com/categoryDe​​scription.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆