精华内容
下载资源
问答
  • URL地址重写

    2014-05-07 14:32:07
    为什么使用URL地址重写?   因为有些浏览器的安全设置,禁用了session.而session的原理则是把session的ID保存在客户端的cookie中。所以这个时候如果cookie功能被禁用的话,所有使用session的功能将失效.如果采用url...
        为什么使用URL地址重写? 
        因为有些浏览器的安全设置,禁用了session.而session的原理则是把session的ID保存在客户端的cookie中。所以这个时候如果cookie功能被禁用的话,所有使用session的功能将失效.如果采用url地址重写技术,则server会把session经过编码以后,写到url地址后面当做参数来传递.这样既提高了客户端的安全性,同时也避免了功能被屏蔽的风险.下面是一个使用url地址重写的servlet例子.其中核心代码为 
    resp.encodeURL(req.getRequestURL().toString()); 

    Java代码  收藏代码
    1. public class SessionTest extends HttpServlet {  
    2.   
    3.     protected void doGet(HttpServletRequest req, HttpServletResponse resp)  
    4.             throws ServletException, IOException {  
    5.         PrintWriter out = resp.getWriter();  
    6.         HttpSession session =req.getSession(true);// true代表先从客户端获取cookie  
    7.           
    8.         out.flush();  
    9.         out.close();  
    10.           
    11.         /* 
    12.          * session默认,也是要把sessionID写到客户端的内存当中(内存cookie) 
    13.          * 重写地址,防止禁用cookie的时候,仍然可以使用session 
    14.          */  
    15.         resp.encodeURL(req.getRequestURL().toString());  
    16.   
    17.         //地址编码,在url中,传递中文  
    18.         org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(String s ,request.getCharacterEncoding());  
    19.     }  
    20.   
    21.     protected void doPost(HttpServletRequest req, HttpServletResponse resp)  
    22.             throws ServletException, IOException {  
    23.         doGet(req, resp);  
    24.     }  
    25.   
    26. }  
    展开全文
  • Url地址重写

    2018-08-10 11:07:00
    一什么是url重写URL重写是截取传入Web请求并自动将请求重定向到其他URL的过程。比如浏览器发来请求hostname/101.aspx,服务器自动将这个请求中定向为http://hostname/list.aspx?id=101。 会人为改为hostname/101....

    一 什么是url重写
    URL 重写是截取传入 Web 请求并自动将请求重定向到其他 URL 的过程。比如浏览器发来请求 hostname/101.aspx ,服务器自动将这个请求中定向为http://hostname/list.aspx ?id=101。 会人为改为 hostname/101.shtml
    url重写的优点在于:
    l    缩短url,隐藏实际路径提高安全性
    l    易于用户记忆和键入。 
    l    易于被搜索引擎收录

    二 实现url重写的基本方法
    1. 创建类项目UrlRewriter,项目中增加三个类URLRewriter.Config.cs,URLRewriter.Form.cs,URLRewriter.Module.cs

    using System;
    using System.Configuration;
    using System.Collections;
    
    namespace URLRewriter.Config
    {
        // Define a custom section containing a simple element and a collection of the same element.
        // It uses two custom types: UrlsCollection and UrlsConfigElement.
        public class UrlsConfig
        {
            public static UrlsSection GetConfig()
            {
                return (UrlsSection)System.Configuration.ConfigurationManager.GetSection("CustomConfiguration");
            }
        
        }
    
    
        public class UrlsSection : ConfigurationSection
        {
            [ConfigurationProperty("urls",IsDefaultCollection = false)]
            public UrlsCollection Urls
            {
                get
                {
                    return (UrlsCollection)this["urls"];
                }
            }
        }
    
        // Define the UrlsCollection that contains UrlsConfigElement elements.
        public class UrlsCollection : ConfigurationElementCollection
        {
            protected override ConfigurationElement CreateNewElement()
            {
                return new UrlConfigElement();
            }
            protected override Object GetElementKey(ConfigurationElement element)
            {
                return ((UrlConfigElement)element).VirtualUrl;
            }
    
            public UrlConfigElement this[int index]
            {
                get
                {
                    return (UrlConfigElement)BaseGet(index);
                }
            }
    
        }
    
        // Define the UrlConfigElement.
        public class UrlConfigElement : ConfigurationElement
        {
    
    
            [ConfigurationProperty("virtualUrl", IsRequired = true)]
            public string VirtualUrl
            {
                get
                {
                    return (string)this["virtualUrl"];
                }
                set
                {
                    this["virtualUrl"] = value;
                }
            }
    
            [ConfigurationProperty("destinationUrl", IsRequired = true)]
            public string DestinationUrl
            {
                get
                {
                    return (string)this["destinationUrl"];
                }
                set
                {
                    this["destinationUrl"] = value;
                }
            }
        }
    }
    
    
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    /// <summary>
    /// FormRewriter 的摘要说明
    /// </summary>
    namespace URLRewriter.Form
    {
        public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter
        {
            public FormRewriterControlAdapter()
            {
            }
    
            protected override void Render(HtmlTextWriter writer)
            {
                base.Render(new RewriteFormHtmlTextWriter(writer));
            }
        }
    
        public class RewriteFormHtmlTextWriter : HtmlTextWriter
        {
            public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
                : base(writer)
            {
                base.InnerWriter = writer.InnerWriter;
            }
            public RewriteFormHtmlTextWriter(System.IO.TextWriter writer)
                : base(writer)
            {
                base.InnerWriter = writer;
            }
    
            public override void WriteAttribute(string name, string value, bool fEncode)
            {
                //If the attribute we are writing is the "action" attribute, and we are not on a sub-control, 
                //then replace the value to write with the raw URL of the request - which ensures that we'll
                //preserve the PathInfo value on postback scenarios
                if (name == "action")
                {
                    HttpContext context = HttpContext.Current;
                    if (context.Items["ActionAlreadyWritten"] == null)
                    {
                        //We will use the Request.RawUrl property within ASP.NET to retrieve the origional 
                        //URL before it was re-written.
                        value = context.Request.RawUrl;
                        //Indicate that we've already rewritten the <form>'s action attribute to prevent
                        //us from rewriting a sub-control under the <form> control
                        context.Items["ActionAlreadyWritten"] = true;
                    }
                }
                base.WriteAttribute(name, value, fEncode);
            }
        }
    
    }
    
    
    using System;
    using System.Web;
    using System.Text.RegularExpressions;
    using System.Configuration;
    using URLRewriter.Config;
    
    namespace URLRewriter
    {
        public class RewriterModule : IHttpModule
        {
            public void Init(HttpApplication app)
            {
                // WARNING!  This does not work with Windows authentication!
                // If you are using Windows authentication, change to app.BeginRequest
                app.AuthorizeRequest += new EventHandler(this.URLRewriter);
            }
    
            protected void URLRewriter(object sender, EventArgs e)
            {
                HttpApplication app = (HttpApplication) sender;
                string requestedPath = app.Request.Path;
            
                // get the configuration rules
                UrlsCollection rules = UrlsConfig.GetConfig().Urls;
    
                for (int i = 0; i < rules.Count; i++)
                {
                    // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory)
                    string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].VirtualUrl) + "$";
    
                    Regex re = new Regex(lookFor, RegexOptions.IgnoreCase);
                    if (re.IsMatch(requestedPath))
                    {
                        string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].DestinationUrl));
                        RewriterUtils.RewriteUrl(app.Context, sendToUrl);
                        break;
                    }
                }
            
            }
    
            public void Dispose() { }
        }
    
    
    
        /// <summary>
        /// Provides utility helper methods for the rewriting HttpModule and HttpHandler.
        /// </summary>
        /// <remarks>This class is marked as internal, meaning only classes in the same assembly will be
        /// able to access its methods.</remarks>
        internal class RewriterUtils
        {
            #region RewriteUrl
            /// <summary>
            /// Rewrite's a URL using <b>HttpContext.RewriteUrl()</b>.
            /// </summary>
            /// <param name="context">The HttpContext object to rewrite the URL to.</param>
            /// <param name="sendToUrl">The URL to rewrite to.</param>
            internal static void RewriteUrl(HttpContext context, string sendToUrl)
            {
                string x, y;
                RewriteUrl(context, sendToUrl, out x, out y);
            }
    
            /// <summary>
            /// Rewrite's a URL using <b>HttpContext.RewriteUrl()</b>.
            /// </summary>
            /// <param name="context">The HttpContext object to rewrite the URL to.</param>
            /// <param name="sendToUrl">The URL to rewrite to.</param>
            /// <param name="sendToUrlLessQString">Returns the value of sendToUrl stripped of the querystring.</param>
            /// <param name="filePath">Returns the physical file path to the requested page.</param>
            internal static void RewriteUrl(HttpContext context, string sendToUrl, out string sendToUrlLessQString, out string filePath)
            {
                // see if we need to add any extra querystring information
                if (context.Request.QueryString.Count > 0)
                {
                    if (sendToUrl.IndexOf('?') != -1)
                        sendToUrl += "&" + context.Request.QueryString.ToString();
                    else
                        sendToUrl += "?" + context.Request.QueryString.ToString();
                }
    
                // first strip the querystring, if any
                string queryString = String.Empty;
                sendToUrlLessQString = sendToUrl;
                if (sendToUrl.IndexOf('?') > 0)
                {
                    sendToUrlLessQString = sendToUrl.Substring(0, sendToUrl.IndexOf('?'));
                    queryString = sendToUrl.Substring(sendToUrl.IndexOf('?') + 1);
                }
    
                // grab the file's physical path
                filePath = string.Empty;
                filePath = context.Server.MapPath(sendToUrlLessQString);
    
                // rewrite the path
                context.RewritePath(sendToUrlLessQString, String.Empty, queryString);
            }
            #endregion
    
            /// <summary>
            /// Converts a URL into one that is usable on the requesting client.
            /// </summary>
            /// <remarks>Converts ~ to the requesting application path.  Mimics the behavior of the 
            /// <b>Control.ResolveUrl()</b> method, which is often used by control developers.</remarks>
            /// <param name="appPath">The application path.</param>
            /// <param name="url">The URL, which might contain ~.</param>
            /// <returns>A resolved URL.  If the input parameter <b>url</b> contains ~, it is replaced with the
            /// value of the <b>appPath</b> parameter.</returns>
            internal static string ResolveUrl(string appPath, string url)
            {
                if (url.Length == 0 || url[0] != '~')
                    return url;        // there is no ~ in the first character position, just return the url
                else
                {
                    if (url.Length == 1)
                        return appPath;  // there is just the ~ in the URL, return the appPath
                    if (url[1] == '/' || url[1] == '//')
                    {
                        // url looks like ~/ or ~/
                        if (appPath.Length > 1)
                            return appPath + "/" + url.Substring(2);
                        else
                            return "/" + url.Substring(2);
                    }
                    else
                    {
                        // url looks like ~something
                        if (appPath.Length > 1)
                            return appPath + "/" + url.Substring(1);
                        else
                            return appPath + url.Substring(1);
                    }
                }
            }
        }
    
    }
    2.在web.config里设置如下:
    
    Code
    <?xml version="1.0"?>
    <configuration>
        <configSections>
        <section name="CustomConfiguration" type="URLRewriter.Config.UrlsSection, URLRewriter" />
      </configSections>
    
      <CustomConfiguration>
        <urls>
          <add virtualUrl="~/microsoft*.*" destinationUrl="~/default.aspx?id=abc" />
          <add virtualUrl="~/microsoft*" destinationUrl="~/default.aspx" />
          <add virtualUrl="~/m/i/c/rosoft.aspx" destinationUrl="~/default.aspx" />
    
          <add virtualUrl="~/cc*.*" destinationUrl="~/default2.aspx?id=11" />
        </urls>
      </CustomConfiguration>
    
        <system.web>
            <httpModules>
                <add type="URLRewriter.RewriterModule, URLRewriter" name="RewriterModule"/>
            </httpModules>
            <authentication mode="Forms"/>
        </system.web>
    </configuration>
    
    
    3.处理回发
    在重写后的url里如果产生回发,例如有一个按钮,又调用了该被重写的aspx,用户浏览器中将会显示该aspx文件实际的地址,也就是http://hostname/default.aspx?id=11。但从用户的角度考虑,如 果单击按钮时突然看到 URL 更改会使他们感到不安。因此必须解决这个问题。
    自己定义一个Actionlessform类,在aspx中不再使用系统提供的form 标记
    
    Code
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    
    namespace ActionlessForm
    {
        /// <summary>
        /// The Form class extends the HtmlForm HTML control by overriding its RenderAttributes()
        /// method and NOT emitting an action attribute.
        /// </summary>
        public class Form : System.Web.UI.HtmlControls.HtmlForm
        {
            /// <summary>
            /// The RenderAttributes method adds the attributes to the rendered <form> tag.
            /// We override this method so that the action attribute is not emitted.
            /// </summary>
            protected override void RenderAttributes(HtmlTextWriter writer)
            {
                // write the form's name
                writer.WriteAttribute("name", this.Name);
                base.Attributes.Remove("name");
    
                // write the form's method
                writer.WriteAttribute("method", this.Method);
                base.Attributes.Remove("method");
    
                // remove the action attribute
                base.Attributes.Remove("action");
    
                // finally write all other attributes
                this.Attributes.Render(writer);
    
                if (base.ID != null)
                    writer.WriteAttribute("id", base.ClientID);
            }
    
        }
    }
    
    
    创建此类并对其进行编译之后,要在 ASP.NET Web 应用程序中使用它,应首先将其添加到 Web 应用程序的 References 文件夹中。然后,要 使用它来代替 HtmlForm 类,做法是在 ASP.NET 网页的顶部添加以下内容:
    
    <%@ Register TagPrefix="af" Namespace="ActionlessForm" Assembly="ActionlessForm" %>

     

    转载于:https://www.cnblogs.com/whl4835349/p/9453834.html

    展开全文
  • urlrewrite url地址重写

    2010-03-18 10:46:14
    urlrewrite url地址重写  郁闷,还要我写够20个字。。我倒!
  • url地址重写

    2007-11-16 11:27:00
    Download source - 8 Kb IntroductionOne of the most popular extensions to the Apache webserver has been mod_rewrite - a filter which rewrites URLs. For example, instead of a URL such as

    How URL rewriting accepts a url and rewrites it

    Introduction

    One of the most popular extensions to the Apache webserver has been mod_rewrite - a filter which rewrites URLs. For example, instead of a URL such as

    http://www.apache.org/BookDetails.pl?id=5
    you could provide a filter which accepts URLs such as
    http://www.apache.org/Book/5.html
    and it will silently perform a server-side redirect to the first URL. In this way, the real URL could be hidden, providing an obfuscated facade to the web page. The benefits are easier to remember URLs and increasing the difficulty of hacking a website.

    Mod_rewrite became very popular and grew to encompass a couple of other features not related to URL Rewriting, such as caching. This article demonstrates URL Rewriting with ASP.NET, whereby the requested URL is matched based on a regular expression and the URL mappings are stored in the standard ASP.NET web.config configuration file. ASP.NET includes great caching facilities, so there's no need to duplicate mod_rewrite's caching functionality.

    As more and more websites are being rewritten with ASP.NET, the old sites which had been indexed by google and linked from other sites are lost, inevitably culminating in the dreaded 404 error. I will show how legacy ASP sites can be upgraded to ASP.NET, while maintaining links from search engines.

    ASP.NET support for URL Rewriting

    ASP.NET provides very limited support out of the box. In fact, it's support is down to a single method:

    void HttpContext.RewritePath(string path)
    which should be called during the Application_BeginRequest() event in the Global.asax file. This is fine as long as the number of URLs to rewrite is a small, finite, managable number. However most ASP sites are in some way dynamic, passing parameters in the Query String, so we require a much more configurable approach.

    The storage location for all ASP.NET Configuration information is the web.config file, so we'd really like to specify the rewrites in there. Additionally, .Net has a fast regular expression processor, giving free and fast search and replace of URLs. Let's define a section in the web.config file which specifies those rewrites:

    <configuration>
    <system.web>
    <urlrewrites>
    <rule>
    <url>/urlrewriter/show/.asp</url>
    <rewrite>show.aspx</rewrite>
    </rule>
    <rule>
    <url>/urlrewriter/wohs/.asp</url>
    <rewrite>show.aspx</rewrite>
    </rule>
    <rule>
    <url>/urlrewriter/show(.*)/.asp</url>
    <rewrite>show.aspx?$1</rewrite>
    </rule>
    <rule>
    <url>/urlrewriter/(.*)show/.html</url>
    <rewrite>show.aspx?id=$1&amp;cat=2</rewrite>
    </rule>
    <rule>
    <url>/urlrewriter/s/h/o/w/(.*)/.html</url>
    <rewrite>/urlrewriter/show.aspx?id=$1</rewrite>
    </rule>
    </urlrewrites>
    </system.web>
    </configuration>
    Notice how we have to escape the period in the url element such as 'show/.asp'. This is a Regular Expression escape and it's a small price to pay for the flexibility of regular expressions. These also show how we set-up a capturing expression using (.*) in the <url> element and refer to that capture in the <rewrite> element with $1

    Configuration Section Handlers

    .Net's configuration mechanism requires us to write code as a "handler" for this section. Here's the code for that:

    <configuration>
    <configSections>
    <sectionGroup name="system.web">
    <section name="urlrewrites" type="ThunderMain.URLRewriter.Rewriter,
    ThunderMain.URLRewriter, Version=1.0.783.30976,
    Culture=neutral, PublicKeyToken=7a95f6f4820c8dc3"/>
    </sectionGroup>
    </configSections>
    </configuration>

    This section handler specifies that for every section called "urlrewrites", there is a class called ThunderMain.URLRewriter.Rewriter which can be found in the ThunderMain.URLRewriter.dll assembly with the given public key token. The public key token is required because this assembly has to be placed into the GAC and therefore given a strong name.

    A section handler is defined as a class which implements the IConfigurationSectionHandler interface. This has one method, Create(), which should be implemented, and in our code that is very simple. It merely stores the urlrewrites element for later use:

    public object Create(object parent, object configContext, XmlNode section) {
    _oRules=section;

    return this;
    }

    Initiating the rewrite process

    Coming back to actually rewriting the URL, as I said earlier, we need to do something in the Application_BeginRequest() event in Global.asax - we just delegate this to another class:

    protected void Application_BeginRequest(Object sender, EventArgs e){
    ThunderMain.URLRewriter.Rewriter.Process();
    }
    which calls the static method Process() on the Rewriter class. Process() first obtains a reference to the configuration section handler (which happens to be an instance of the current class) and then delegates most of the work to GetSubstitution() - an instance method of this class.
    public static void Process() {
    Rewriter oRewriter=
    (Rewriter)ConfigurationSettings.GetConfig("system.web/urlrewrites");

    string zSubst=oRewriter.GetSubstitution(HttpContext.Current.Request.Path);

    if(zSubst.Length>0) {
    HttpContext.Current.RewritePath(zSubst);
    }
    }
    GetSubstitution() is just as simple - iterating through all possible URL Rewrites to see if one matches. If it does, it returns the new URL, otherwise it just returns the original URL:
    public string GetSubstitution(string zPath) {
    Regex oReg;

    foreach(XmlNode oNode in _oRules.SelectNodes("rule")) {
    oReg=new Regex(oNode.SelectSingleNode("url/text()").Value);
    Match oMatch=oReg.Match(zPath);

    if(oMatch.Success) {
    return oReg.Replace(zPath,oNode.SelectSingleNode("rewrite/text()").Value);
    }
    }

    return zPath;
    }

    Installing the sample code

    Extract the code into a URLRewriter folder, then turn this into a virtual directory using the Internet Information Services MMC control panel applet. Compile the code use the 'Make Rewriter.bat' batch script into the bin sub-folder. Then add bin/ThunderMain.URLRewriter.dll to the Global Assembly Cache by copying and pasting the dll into %WINDIR%/assembly using Windows Explorer. Finally, navigate to http://localhost/URLRewriter/default.aspx and try the demo URLs listed.

    None will actually work because there's one last thing we have to be aware of...

    Finally

    There's one major caveat with all this. If you want to process a request with a file extension other than .aspx such as .asp or .html, then you need to change IIS to pass all requests through to the ASP.NET ISAPI extension. Unfortunately, you will need physical access to the server to perform this, which prevents you from simply XCOPY deploying your code to an ISP.

    Adding a mapping for all file types

    We've added the HEAD, GET and POST verbs to all files with .* file extension (ie all files) and mapped those to the ASP.NET ISAPI extension - aspnet_isapi.dll.

    A mapping for all file types has been added

    The complete range of mappings, including the new .* mapping.

    posted on 2004-06-02 09:48 edobnet 阅读(6505) 评论(18)  编辑  收藏 所属分类: .Net

    评论:
    #1楼  2004-06-02 10:50 | unruledboy(灵感之源) [未注册用户]
    mmmm,的确有点意思
      回复  引用  查看    
    #2楼  2004-06-02 11:15 | 陈叙远 [未注册用户]
    我通常写一个httphandler配合URLRewrite做url参数隐藏
      回复  引用  查看    
    #4楼  2004-06-02 11:37 | Hover [未注册用户]
    Adding a mapping for all file types
    这里在windows server 2003下就不行了呀
    Extension: 这里输入.*的话,出现错误的扩展名格式
    该如何解决
      回复  引用  查看    
    #5楼  2004-06-02 11:44 | dudu [未注册用户]
    通过“添加”按钮右下方的“插入”按钮。
      回复  引用  查看    
    #7楼  2004-06-03 11:29 | 小春 [未注册用户]
    我试不出来:(
      回复  引用  查看    
    #8楼  2004-06-07 15:50 | edobnet [未注册用户]
    自己写的一个方法:
    global.asax.cs文件

             protected void Application_BeginRequest(Object sender, EventArgs e)

             {

                  try

                  {

                       string path=Server.MapPath("~/ReWriter.config");

                       XPathDocument myXPathDocument = new XPathDocument(path);

                       XPathNavigator myXPathNavigator = myXPathDocument.CreateNavigator();

     

                       XPathNodeIterator myXPathNodeIterator =  myXPathNavigator.Select ("//rule");

                       System.Text.RegularExpressions.Regex oReg;

                       string ReWriteUrl;

     

                       while (myXPathNodeIterator.MoveNext())

                       {

                           //oReg=new Regex(oNode.SelectSingleNode("url/text()").Value);

                           XPathNavigator nav2 = myXPathNodeIterator.Current.Clone();

                           string oldString="",newString="";

                           XPathNodeIterator it2 = nav2.Select("old");

                           while(it2.MoveNext())

                           {

                                oldString = it2.Current.Value;

                                break;

                           }

                           it2 = nav2.Select("new");

                           while(it2.MoveNext())

                           {

                                newString = it2.Current.Value;

                                break;

                           }

                           if(oldString != "" &&  newString != "")

                           {

                                     oReg = new System.Text.RegularExpressions.Regex(oldString);

                                     if(oReg.IsMatch(Request.Url.ToString()))

                                     {

                                         ReWriteUrl = oReg.Replace(Request.Url.ToString(),newString);

                                         HttpContext.Current.RewritePath(ReWriteUrl);

                                         break;

                                     }

                           }

                       }

                      

                  }

                  catch

                  {

                  }

     

             }

    ReWriter.config内容(配制ReWriter信息)

    <?xml version="1.0" encoding="utf-8" ?>

    <ReWriterUrls>

              <rule>

                   <old>(.*)/TestUrlRe/file(.*)/(.*)/.html</old>

                   <new>../WebForm1.aspx?id=$2&amp;type=$3</new>

              </rule>

              <rule>

                   <old>(.*)/TestUrlRe/t(.*)/(.*)/.html</old>

                   <new>../WebForm1.aspx?tid=$2&amp;ttype=$3</new>

              </rule>

    </ReWriterUrls>


      回复  引用  查看    
    #9楼  2005-01-06 17:17 | 网上购物 [未注册用户]
    非常非常有用,谢谢了!!
      回复  引用  查看    
    #10楼  2005-01-06 18:05 | 汽车 [未注册用户]
    hao
      回复  引用  查看    
    #11楼 [楼主] 2005-01-17 09:00 | edobnet
    你需要把后缀为.html的文件的解析器设为.net解析.

    IIS管理器+web站点+右键属性+主目录+配置+添加一个和.aspx类似的解析就行了!
      回复  引用  查看    
    #12楼  2005-01-18 10:27 | 汽车 [未注册用户]
    "你需要把后缀为.html的文件的解析器设为.net解析.

    IIS管理器+web站点+右键属性+主目录+配置+添加一个和.aspx类似的解析就行了! "

    不行呀,
    我用的是你自己写的那个ReWriter.config

      回复  引用  查看    
    #13楼  2005-03-31 22:11 | 中美网络 [未注册用户]
    我的网站也采用了这样的方式
      回复  引用  查看    
    #14楼  2005-07-25 11:57 | 蓝剑 [未注册用户]
    不错,
    我的blog也是用这个
    只不过action问题还没有解决,即url地址跟action值不同
      回复  引用  查看    
    #15楼  2005-08-03 16:59 | 蓝星空
    偶的网站就用了这个技术,非常有利于搜索引擎的收录。
      回复  引用  查看    
    #16楼  2006-05-14 00:12 | 九寨沟旅游 [未注册用户]
    不错,努力!
      回复  引用  查看    
    #17楼  2006-09-26 10:05 | 新光饰品 [未注册用户]
    果然啊
      回复  引用  查看    
    #18楼  2006-12-22 15:48 | henry3695 [未注册用户]
    very good
      回复  引用  查看    
    <script type="text/javascript"> function pageLoad() { Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(handleInitializeRequest); //Sys.WebForms.PageRequestManager.getInstance().add_endRequest(handleEndRequest); } function handleInitializeRequest(sender, args) { var prm = Sys.WebForms.PageRequestManager.getInstance(); var eid = args.get_postBackElement().id; if (eid.indexOf("DeleteLink")>0) { args.get_postBackElement().innerHTML = "正在删除..."; } else if (eid.indexOf("btnSubmit")>0) { document.getElementById("AjaxHolder_PostComment_ltSubmitMsg").innerHTML="正在提交..."; document.getElementById("AjaxHolder_PostComment_btnSubmit").disabled = true; } else if(eid.indexOf("refreshList")>0) { document.getElementById("AjaxHolder_PostComment_refreshList").innerHTML="正在刷新..."; } } function TempSave(ElementID) { try { CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value); CommentsPersistDiv.save("CommentXMLStore"); } catch(ex) { } } function Restore(ElementID) { CommentsPersistDiv.load("CommentXMLStore"); document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent"); } </script>  
    展开全文
  • jvaWeb之URL地址重写

    2019-07-21 13:41:00
    URL地址重写是对客户端不支持Cookie的解决方案(正常情况下Seesion要依靠Cookie来识别的)。URL地址重写的原理是将该用户Session的id信息重写到URL地址中。服务器能够解析重写后的URL获取Session的id。这样即使客户端...

    URL地址重写是对客户端不支持Cookie的解决方案(正常情况下Seesion要依靠Cookie来识别的)。URL地址重写的原理是将该用户Session的id信息重写到URL地址中。服务器能够解析重写后的URL获取Session的id。这样即使客户端不支持Cookie,也可以使用Session来记录用户状态。HttpServletResponse类提供了encodeURL(Stringurl)实现URL地址重写,例如:
    在这里插入图片描述
    该方法会自动判断客户端是否支持Cookie。如果客户端支持Cookie,会将URL原封不动地输出来。如果客户端不支持Cookie,则会将用户Session的id重写到URL中。重写后的输出可能是这样的:
    在这里插入图片描述
    即在文件名的后面,在URL参数的前面添加了字符串“;jsessionid=XXX”。其中XXX为Session的id。分析一下可以知道,增添的jsessionid字符串既不会影响请求的文件名,也不会影响提交的地址栏参数。用户单击这个链接的时候会把Session的id通过URL提交到服务器上,服务器通过解析URL地址获得Session的id。
    如果是页面重定向(Redirection),URL地址重写可以这样写:
    在这里插入图片描述
    由于大部分的手机浏览器都不支持Cookie,程序都会采用URL地址重写来跟踪用户会话。索性禁止Session使用Cookie,统一使用URL地址重写会更好一些。Java Web规范支持通过配置的方式禁用Cookie。下面举例说一下怎样通过配置禁止使用Cookie。

    打开项目根目录下的META-INF文件夹(跟WEB-INF文件夹同级,如果没有则创建),打开context.xml(如果没有则创建),编辑内容如下: /META-INF/context.xml:
    在这里插入图片描述
    部署后TOMCAT便不会自动生成名JSESSIONID的Cookie,Session也不会以Cookie为识别标志,而仅仅以重写后的URL地址为识别标志了

    注意:该配置只是禁止Session使用Cookie作为识别标志,并不能阻止其他的Cookie读写。也就是说服务器不会自动维护名为JSESSIONID的Cookie了,但是程序中仍然可以读写其他的Cookie。

    展开全文
  • Url地址重写和SEO

    热门讨论 2019-01-30 10:02:47
    Url地址重写是将带参数的地址改写为不带参数的地址,而不带参数的地址优先级比较高。这就像百度浏览器中获取一些数据信息时,利用爬虫发送的请求进行数据获取,向页面请求数据时就要利用页面地址,而当检测到带参数...
  • Apache中URL地址重写

    2013-12-16 19:40:58
    第一种方法: Apache环境中如果要将URL地址重写,正则表达式是最基本的要求,但对于一般的URL地址来说,基本的匹配就能实现 我们大部分要求,因此除非 是非常特殊的URL地址,但这不是我要讨论的范围,简单几招学会...
  • Apache的URL地址重写 RewriteCond与RewriteRule
  • 什么是Nginx rewrite和Apache等Web服务软件一样,Nginx rewrite的主要功能也是实现URL地址重写。Nginx的rewrite规则需要PCRE软件的支持,即通过Perl兼容正则表达式语法进行规则匹配。前文在安装Nginx软件时就已经...
  • Urlrewrite(url地址重写)和UrlRewriteFilter Urlrewrite: urlRewrite就是我们通常说的地址重写,用户得到的全部都是经过处理后的URL地址 UrlRewrite的含义: 优点 1、提高安全性,可以有效的避免一些参数名、ID...
  • cookie与session详解、url地址重写:https://www.cnblogs.com/l199616j/p/11195667.html
  • URL地址重写项目

    2014-06-05 10:59:55
    伪静态URL重写实际就是以静态地址(如:http://127.0.0.1:8080/pro/index.html)访问地态网页的方法(如:http://127.0.0.1:8080/pro/index.jsp)。 ...把静态的URL地址转换成动态地址,发起请求。
  • Apache的URL地址重写 http://hi.baidu.com/sonan/blog/item/c408963d89468208bba16716.html 第一种方法:Apache环境中如果要将URL地址重写,正则表达式是最基本的要求,但对于一般的URL地址来说,基本的匹配就能实现...
  • C# URL重写 URL重定向 地址重写 .net源码 核心代码 简单易用源码
  • php url地址重写

    2015-12-13 11:49:00
    地址重写: urlRewrite: 就是: 1. 将php的地址index.php不写只写Action模块和function方法, 或者 2. php地址转变成html地址, 就是一种假的html, 所以叫伪静态.(除了伪静态外, 还有真的静态化, 就是真的将原来php的...
  • nginx rewrite(nginx url地址重写)

    千次阅读 2013-10-22 06:46:06
    本文介绍下,在nginx中配置url地址重写的方法,有需要的朋友参考下。 在nginx中,Rewrite用来实现URL的重写,Nginx的Rewrite规则采用Pcre,perl兼容正则表达式的语法规则匹配,如果需要Nginx的Rewrite功能,在...
  • Url地址重写与优化的作用主要表现如下 ⒈缩短Url,隐藏实际路径提高安全性。 ⒉易于用户记忆和键入。 ⒊易于被搜索引擎收录。 以下是我在MVC3中准备重写的一些常见的Url http://www.xxxx.com/pub/users //用户...
  • URL重写这东西在工作中用了很多次了,但每次都忘记了要记得把知道的积累下来。 哎,要么认为没必要,要么就是没时间?! 一、Apache 篇 官方地址:...
  • 该文件是一个asp.neturl地址重写的简单实例.
  • 1. 去掉地址中的/api部分 location /api/ws{ rewrite "^/api(.*)$" $1; } 2. /ws地址将转发http://47.119.131.185 location /ws { proxy_pass http://47.119.131.185; } 3. 转换/api/interface为/interface...
  • url重写是指通过配置conf文件,以让网站的url中达到某种状态时则定向/跳转到某个规则,比如常见的伪静态、301重定向、浏览器定向等 rewrite 语法 在配置文件的server块中写,如: server { rewrite 规则 定向路径 ...
  • UrlRewriter url 地址重写

    2014-07-24 14:49:50
    方法一:参考地址http://tuckey.org/urlrewrite/ 方法二:shi

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,497
精华内容 998
关键字:

url地址重写