简体   繁体   English

htaccess重写根文件夹请求

[英]Htaccess rewrite root folder request

Is there a possible way to point this: 有没有办法指出这一点:

domain.com/test

to: 至:

domain.com/page.php?a=test

This has been bothering me for a while. 这困扰了我一段时间。 Perhaps something like: 也许像这样:

RewriteRule ^/(.*)$ page.php?a=$1 [NC] 

I'm trying to point a request like domain.com/test to page.php and pass the parameter. 我试图将诸如domain.com/test类的请求指向page.php并传递参数。

If you want to map all the request, include domain.com/test.php to domain.com/page.php?a=test.php , you can: 如果要映射所有的请求,包括domain.com/test.phpdomain.com/page.php?a=test.php ,您可以:

RewriteRule ^/(.*)$ /page.php?a=$1 [NC]

If you only want simply map the request path: domain.com/test to domain.com/page.php?a=test , you should: 如果只想将请求路径: domain.com/test映射到domain.com/page.php?a=test ,则应该:

RewriteRule ^/([a-zA-Z\-_]*)$ /page.php?a=$1 [NC]

Notice: After map, the url display in browser will still be http://domain.com/test . 注意:映射后,浏览器中的url显示仍为http://domain.com/test

Yes, WordPress does this rather successfully with a combination of .htaccess and php... Here's another post that explains it pretty well: 是的,WordPress通过.htaccess和php的组合非常成功地完成了此操作……这是另一篇很好地解释它的文章:

How WordPress permalink system works? WordPress永久链接系统如何工作?

Here's a link that gives the actual WordPress .htaccess code for rewrites: 这是一个提供实际WordPress .htaccess代码进行重写的链接:

http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29 http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29

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

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