Apache1.3 URL Rewriting Guide 1

 

Apache HTTP Server Version 1.3

Is this the version you want? For more recent versions, check our documentation index.

Apache 1.3
URL Rewriting Guide

Originally written by
Ralf S. Engelschall <rse@apache.org>
December 1997

December 1997

This document supplements the mod_rewrites the mod_rewrite reference documentation. It describes how one can use Apache's mod_rewrite to solve typical URL-base problem with webmasters are often confronted. We give detailed desciptions on how to solve each problem each problem by configuring URL rewriting rulesets.

Introduction to mod_rewrite

The Apache module mod_rewrite is a killer one, i, e, it is a really sophisticate module which provides a powerful way to do URL manipulations. With it you can do nearly all types of URL manipulations you ever dreamed about. The price you have to pay is to accept complexity, because mod_rewrite's major drawback is that it is not easy to understand and use for beginner. And even Apache experts sometimes discover new aspects where mod_rewrite can help.

In other words:  With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power. This paper tries to give you a few initial success events to avoid  the first case by presenting already invented solutions to you.

Practical Solutions

Here come a lot of pratctical solutions I've either invented myself or collected from other peoples solutions in the past, Feel free to learn the black magic of URL rewriting from example.

ATTENTION: Depending on your server-configurtion it can be neccessary to slightly change the examples for you situation, e.g. adding the [PT] flag when additonally using mod_alias and mod_userdir, etc. Or rewriting a ruleset to fit in .htaccess context instead of per-server context. Always try to understand what a particular ruleset really does before you use it order to avoid problems.

URL Layout

Canonical URLs

Description:
  On some webserver there are more than one URL for a resource. Usually there are canonical URLs (which should be actually used and distributed ) and those which are just shortcuts, internal ones, etc. Independent which URL the user supplied with the request he should finally see the canonical one only.

Solution:
  We do an external HTTP redirect for all non-canonical URLs to fix them in the location view of the Browser and for all sbsequent requests.  In the example ruleset below we replace  /~user by the canonical /u/user and fix a missing trailing slash for /u/user.

RewriteRule ^/~([^/])+)/?(.*)     /u/$1/$2  [R]
RewriteRule ^/([uge])/([^/]+)$    /$1/$2/   [R]

Description:
  The goal of this to force the use of a particuclar hostname, in preference to other hostname which may be used to reach the same site, For example, if you wish to force the use of www.example.com instead of example.com. you might use a variant of the following recipe.
Solution:
  #For sites running on a port other than 80
RewriteCond %{HTTP_HOST}   !^fully/.qualified/.domain/.name [NC]
RewriteCond %{HTTP_HOST}  !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)   http://fully.qualified.domain.name:%{SERVER_PORT}?$1 [L,R]
# And for a site running on 80
RewriteCond %{HTTP_HOST} !^fully/.qualified/.domain/.name[NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)  http://fully.qualified.domain.name /$1 [L,R]

Trailing Slash Problem

Description:
 Every webmaster can sing asong about the problem of the trailing slash on URLs referencing directories, If they are missing, the server dumps an error, because if you say /-quux/foo instead of /-quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually is tries to fix it themself in most of the cases. but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewriting to CGI scripts etc.
Solution :
  The solution to this subtle problem is to the server add the trailing slash automatically. To do this correctly we have to use an external redirect, so the browser correctly requests subsequent images etc. if we only did a internal rewrite, this would only work for the directory page, but would go wrong when any images are included into this page with relative URLs, because the browser would request an in_lined object. For instance, a request for image.gif in /-quux/foo/index.html would become /-quux/image.gif without the external redirect!

  So, to do this trick we write:
 RewriteEngine on
 RewriteBase   /-quux/
 RewriteRule   ^foo$  foo/ [R]
The crazy and lazy can even do the following in the top-level .htaccess file of their homedir. But notice that this creates some processing overhead
 RewriteEngine on
 RewriteBase  /~quux/
 RewriteCond  %{REQUEST_FILENAME} -d
 RewriteRule   ^(.+[^/])$               $!/ [R]

Webcluster through Homogeneous URL Layout
Description:
 We want to create a homegenous and consistent URL layout over all WWW servers on a Intranet webcluster,i.e, all URLs (per definition server local and thus server dependend !) becaome actually server independ!What we want is to give the WWW namespace acondidtent server-independend layout: no URL should have to include any physically correct  target server.The cluster itself should drive us automatically to the automatically to the physical target host.
Solution:
First, the konwledge of the target servers come from(distributed) external
maps which contain information where our users,groups and entities stay, The have the form
user1 server_of_user1
user2 server_of_user2
:      :
We put them into files map .xxx-to-host. Second we need to instruct all servers to redirest URLs of the forms
/u/user/anypath
/g/user/anypath
/e/entity/anypath

to

http://physical-host/u/user/anypath
http://physical-host/u/user/anypath
http://physical-host/u/user/anypath



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
重新编写深度生成模型是指对已有的深度生成模型进行重新设计和改进,以提高其性能和效率。深度生成模型是一种基于人工神经网络的模型,用于从输入数据中生成符合特定分布的新数据。这种模型在图像生成、语音生成和自然语言处理等领域有着广泛的应用。重新编写深度生成模型可能涉及到以下几个方面的工作: 首先,对原有模型的架构进行调整和优化。可能需要更换不同类型的神经网络层、调整网络的深度和宽度,以及引入新的激活函数和正则化方法,以改善模型对复杂数据分布的建模能力。 其次,对损失函数和优化算法进行修改。这包括选择更适合特定任务的损失函数,以及调整学习率、批次大小和训练迭代次数等超参数,以加速训练过程并提高模型收敛性能。 另外,考虑引入新的技术和概念。例如,可以借鉴最新的深度学习技术,如自监督学习、迁移学习和元学习,以提高模型的泛化能力和适应性。 最后,需要对重新编写的模型进行充分的测试和评估。这包括在各种真实数据集上进行性能测试,进行与其他模型的比较,以及对模型的可解释性和鲁棒性进行分析。 总的来说,重新编写深度生成模型是一个既需要理论深度又需要实践经验的工作,需要对模型架构、损失函数、优化算法等方面进行全面的考量和改进,以获得更加高效和强大的生成模型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值