繁体   English   中英

.htaccess文件的重写规则

[英]rewrite rule for .htaccess file

我需要在我的网站上编写重定向规则。我正在使用codeigniter.so,因此它将对所有页面使用index.php。 所以我的第一个规则是

RewriteRule ^(.*)$ /index.php/$1 [L]

现在我想添加一些更多的东西,如下。

我的要求首先:

输入example.com/index.php/search/query

要重定向的网址example.com/search?q=query

和,

输入example.com/index.php/search/query&c=abc&s=xyz&p=1

要重定向的网址example.com/search?q=query&c=abc&s=xyz&p=1

而已。

任何人都可以破解此代码。 请...

提前致谢。

编辑:告诉一些参考网站,以了解更多有关编写.htaccess文件的规则和条件语法的信息。

在html代码中,您必须这样编写:

<a href='http://www.domain.com/index/211/title-goes-here'>url_text</a>

并在htaccess文件中修改以下内容:

Options +SymLinksIfOwnerMatch

RewriteEngine on

RewriteRule ^([a-zA-Z-]+)$ index.php?action=$1 [NC,L]

RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L]

RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)-([0-9-]+)$ index.php?action=$1&saction=$2&sid=$3 [NC,L]

RewriteRule ^([a-zA-Z-]+)/([0-9-]+)$ index.php?action=$1&id=$2 [NC,L]

RewriteRule ^([0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*).html$ index.php?action=details&id=$1&p1=$2&p2=$3&p3=$4 [NC,L]

使用()标记需要提取和使用的数据;

使用$ x,其中x = 1,2,3,...

$ x是值

您拥有的()越多,您拥有的$ x越多

其中:RewriteRule ^(成员)-([0-9-] +)$ index.php?action = member&id = $ 2 [NC,L]

(成员)为$ 1,([0-9] +)为$ 2

你理解吗?

暂无
暂无

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

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