htaccess的 - 删除"的index.php"从URL和重定向 [英] htaccess - remove "index.php" from URL and redirect

查看:143
本文介绍了htaccess的 - 删除"的index.php"从URL和重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站,我是用的URL地址,如

At my website, I was using URL addresses such as

http://me.example.com/index.php?p=home

然后,我决定使用

Then I decided to use

http://me.example.com/?p=home

这一切都自动的工作没有任何的.htaccess文件。但其中含有的index.php的地址也仍然有效。有些网站有链接到我的老格式的网站。我希望人们停止使用旧格式,并将其重定向到新格式的URL,每当他们用老的格式。所有我想要做的是从URL中删除的index.php,改变这个URL在访问者的浏览器。

It all worked automatically without any ".htaccess" file. But addresses which contain "index.php" also still work. Some sites have links to my site in "old" format. I want people to stop using this "old" format and redirect them to the "new" format URL, whenever they use "old" format. All I want to do is to remove "index.php" from URL and also change this URL in visitor's browser.

推荐答案

下面是code,将在.htaccess去下DOCUMENT_ROOT:

Here is the code that will go in .htaccess under DOCUMENT_ROOT:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php/?$ / [L,R=301,NC]

这篇关于htaccess的 - 删除"的index.php"从URL和重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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