简体   繁体   English

Apache改写规则怎么写?

[英]How to write the Apache rewrite rule?

Currently I have URLs like these:目前我有这样的网址:

http://example.com/d/tag.php?n=1&tag=php
http://example.com/d/tag.php?n=1&tag=cms

I want to add the rewrite rule in .htaccess file.to make the URL like this:我想在.htaccess文件中添加重写规则。使 URL 像这样:

http://example.com/tag/1/php

How to write such rule?如何编写这样的规则?

Here you gou:给你:

 RewriteEngine On
 RewriteRule ^tag/([0-9]*)/(.*)$ tag.php?n=$1&tag=$2

Don't forget to put that in your .htaccess file under your direcrory ( d ).不要忘记将它放在您的目录( d )下的.htaccess文件中。

have a look to this link看看这个链接

mod_rewrite redirect all the requests linke http://exmple.com/d/tag.php?n=1&tag=php to a specific page there you have to write the code that handle the request mod_rewrite 将所有请求链接http://exmple.com/d/tag.php?n=1&tag=php重定向到特定页面,您必须编写处理请求的代码

Hope this helps希望这可以帮助

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

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