重写一切的index.php,但可以知道哪一页它是从哪里来的。 [英] Rewrite everything to index.php but be able to know what page it came from.

查看:109
本文介绍了重写一切的index.php,但可以知道哪一页它是从哪里来的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重写一切到我的网站的index.php文件是 www.examplesite.com .htaccess文件。

I need an .htaccess file that rewrite everything to the index.php of my site that is www.examplesite.com.

例如:我打开 www.examplesite.com/designs/designs.php?tab=2013 ,我希望自己的网站加载 HTTP: //examplesite.com/index.php 在后台,而住在同一个URL。子文件夹设计,文件 designs.php 将不会存在于服务器上,并将从加载在内其他服务器的index.php 根据所输入的URL。

Example : I open www.examplesite.com/designs/designs.php?tab=2013 and I want the site to load http://examplesite.com/index.php in background, while staying on the same URL. The sub-folder designs and the file designs.php will not exist on the server, and will be loaded from an other server inside of the index.php depending of the entered URL.

我的.htaccess中已经包含了一些事情,我真的不知道这意味着什么,但我想我需要保持年初到的RewriteCond,我不知道这一点:

My .htaccess already contains some things, I don't really know what it means but I think I need to keep the beginning up to the RewriteCond, I'm not sure about that :

RewriteEngine on

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.examplesite.com
AuthUserFile /home/designerr/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/designerr/public_html/_vti_pvt/service.grp

RewriteCond %{HTTP_HOST} ^an_other_domain_i_own\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.an_other_domain_i_own\.com$
RewriteRule ^/?$ "http\:\/\/examplesite\.com" [R=301,L]

我注意到有一个301重定向,我可能会需要建立一个网站地图再次索引。

I noticed there is a 301 redirect, I will probably need to build a site-map to be indexed again.

于是,我应该把在新的.htaccess?我还需要知道在C什么是看到客户的实际URL我的PHP $ C $,我认为这是与 $ _ SERVER ['REQUEST_URI'] $ _ SERVER ['REDIRECT_URL'] ,我不知道。

So, what should I put in the new .htaccess ? I also need to know in my PHP code what is the actual URL seen by clients, I think it's with $_SERVER['REQUEST_URI'] or $_SERVER['REDIRECT_URL'], I'm not sure.

*顺便说一句我的网站的真实姓名都不 examplesite.com an_other_domain_i_own.com ,但我在这篇文章改变了它,以确保我的.htaccess的发布不提供您的任何方式来破解我的网站之类的任何事情。

*By the way the real name of my sites are not examplesite.com and an_other_domain_i_own.com, but I changed it in this post to ensure that the publication of my .htaccess does not provide you any ways to hack my site or any things like that.

推荐答案

您可以尝试这些重写规则(前提是您的第一行仍然是:重写引擎)

You could try these rewrite rules (provided your top line remains: rewrite engine on)

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

这些语句直接调用到index.php如果目录和放大器;文件不能在服务器上找到。

These statements direct calls to index.php if the directory & file cannot be found on the server.

REQUEST_URI将提供网址

REQUEST_URI would provide the url

这篇关于重写一切的index.php,但可以知道哪一页它是从哪里来的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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