重写URL与htaccess的 [英] rewriting urls with htaccess

查看:118
本文介绍了重写URL与htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做的是改变对我的网站的链接,例如从

What I need to do is change the links on my website, for example from

www.mywebsite.com/index.php

www.mywebsite.com/index.php

www.mywebsite.com/index.php?action=about_us

www.mywebsite.com/index.php?action=about_us

www.myswebsite.com/index.html

www.myswebsite.com/index.html

www.myswebsite.com/about_us.html

www.myswebsite.com/about_us.html

有人告诉我的的htaccess 的来达致这和我presume这是实现了与某种常规EX pression。

I was told htaccess was used to acheive this and I presume this is achieved with some sort of regular expression.

我怎样才能实现这个结果?

How can I achieve this result?

推荐答案

打开重写引擎。该重写规则将获取的页面中的第二个参数时,第一个参数被调用。因此, www.myswebsite.com/about_us.html 将加载 www.mywebsite.com/index.php?action=about_us ,但在地址栏中的URL仍将 www.myswebsite.com/about_us.html 。该 [NC] 在刚刚结束使得它不区分大小写。

Turn on the rewrite engine. The RewriteRule will fetch the page in the second parameter when the first parameter is called. So www.myswebsite.com/about_us.html will load www.mywebsite.com/index.php?action=about_us, but the URL in the address bar will still be www.myswebsite.com/about_us.html. The [NC] at the end just makes it case insensitive.

RewriteEngine On
RewriteRule ^/about_us\.html$ index.php?action=about_us [NC]

更多信息: http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

More info: http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

这篇关于重写URL与htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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