重写规则问题
有什么方法可以使用 RewriteRule 显示这些链接:
/articles_history.php
/articles_geography.php
as
/articles/history.html
/articles/geography.html
我在根目录上创建了一个 .htacesss 文件,想知道是否通过在 .htaccess 文件中放置某种代码可以实现上述目的。
Is there any way i can use RewriteRule to show these links:
/articles_history.php
/articles_geography.php
as
/articles/history.html
/articles/geography.html
I created a .htacesss file on my root directory and would like to know if the above is possible by placing some kind of code in the .htaccess file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。
请参阅 http://httpd.apache.org/docs/2.2/mod/mod_rewrite .html
除了RewriteRule之外,您通常还需要通过RewriteEngine指令打开重写引擎。
Yes it is.
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
In addition to RewriteRule, you also need to usually turn the rewrite engine on by the RewriteEngine directive.
在您的 .htaccess 中尝试一下:
对于任意输入:
Try this in your .htaccess:
And for an arbitrary input: