English 中文(简体)
将所有网站的流量转至PHP的手稿,陷阱?
原标题:Redirect all website traffic to PHP handler, pitfalls?

I m 利用PHP建造一条习俗微型产品。 I m目前采用共同技术,将所有不存在的档案要求改用单一购买力平价指数和基于这一途径的产出内容。 这页数是罚款的。

阿帕奇·朗德-重新制定规则;

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

由于实际档案被直接送达,实际存在的资源档案(剂量、 c、 j等)。 我这里的问题是,这暴露了这些档案的真正服务器途径,例如:

“/mycms/websites/google/themes/blue/cs/划式s.cs”

我倾向于掩盖这一例子;

“主题/类型/类型”

由于这一请求不会存在,因此,利用我目前的结构,将转而转向我的个人住房指数。 我可以现实地开始为每个网站和每个主题增加阿帕奇朗德标准规则。 因此,目前唯一解决这一问题的方法是,通过我的PHP手稿处理所有资源档案,将其用来阅读服务器上的档案,并找出正确的内容类型。

首先,如果这是唯一的解决办法,那么我需要小心谨慎,不要破坏任何提高业绩的措施,例如要求打碎?

第二,用“地位”的话来说,是否有更好的办法?

最佳回答

如果你正在建设新的客户关系管理系统,那么,现在就开始就能够把静态资产储存在网络根基上,以及你在网根之外的图书馆。 仅保留网络根基中的指数.php。

因此,这首先给这 tree树:

path/
  -to/
      -cms/
         -www/
             -index.php
              -static
                  -js/ /* cms shared js */
                   -css/ /* cms shared css */
                   -images/ /* cms shared images */
          -lib/
              -cms.php /*lots of php files related to the cms*/

现在,你希望在同一厘米处内处理几个网站,并隐藏固定资源的网站名称。 牵头2个问题:

  • why handling several websites with the same cms installation, deploying the cms several time, one for each website is usually better, IMHO. But anyway, why not.
  • why hiding the site name on the static resource url?

就第二个问题而言,我只能看到这样做的原因之一,它有助于优化这些资产的切身政策。 您要说,www.example1.com/static/images/foo.pngwww.example2.com/static/images/foo.png相同。 精心配置的反向代理可以做到这一点。 但是,良好的分数还可以处理共享静态资源的共同领域,例如:cdn.example.com/static/commd/images/foo.png

Now you are maybe actually having ugly url like: http://www.example2.com/cms/www.examples2.com/static/images/foo.png. And yes this is quite ugly, simply because you could try to check some static assets from example1.com while browsing example2.com, by altering the link manually. So someone could send an url http://www.seriouswebsite.com/static/images/adultcontent.com/foo.png claiming that seriouswebsite.com is storing some ugly picture, simply because adultcontent.com is handled in the same server with the same cms. Now that s something not very important, done in other cms, like in Drupal multidomain default managment for example. I assume you have this situation, that you do not want, and you would like it to be handled by an url in this form : http://www.example2.com/images/foo.png.

www.un.org/Depts/DGACM/index_spanish.htm 关于与PHP

因此,现在你们的多层树种是:

path/
  -to/
      -cms/
         -www/
             -index.php
              -static
                  -js/ /* cms shared js */
                   -css/ /* cms shared css */
                   -images/ /* cms shared images */
              -domain1.com/
                  -static
                        -js/
                         -css/
                         -images/
              -domain2.net/
                  -static
                        -js/
                         -css/
                         -images/
          -lib/
              -cms.php /*lots of php files related to the cms*/

解决办法之一是固定内容的改写规则,先用域名确定静态ur,但你将减少装载共同资产的可能性。 如果具体领域的资源与地方一样具有关键词,那么你仍然可以这样做。

因此:

# private image
/path/to/cms/www/domain1.com/static/images/foo.png => http://domain1.com/static/local/images/foo.png
# shared by the cms
/path/to/cms/www/static/images/foo.png => http://domain1.com/static/images/foo.png

沉积规则现在必须探测static/ local部分并改写到static/domain1.com。 现行领域为领域1.com。 与此类似(未测试):

RewriteRule ^static/local/(.*)$ %{HTTP_HOST}/static/$1 [QSA,L]

这一解决办法增加了几个限制:

  • You should have a dedicated virtualHost (better) or rewriteRule (for .htaccess fallbacks) rewritting all alternate domain name access to a canonical domain name for handled domains. It s also better for SEO. as http://domain1.com/static/images/foo.png will be ok but not http://www.domain1.com/static/images/foo.png or http://foo.domain1.com/static/images/foo.png, and http://DOmaiN1.com/static/images/foo.png should be checked.
  • The subdirectory storing assets must be named exactly like the HHTP_HOST, no liberty on that.
  • this rule does not prevent usage of domain1.com/static/images/foo.png direclty, so users could still build bad links, some other rewriteRule with 301 redirects could be added.
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签