Shortening the URL with RewriteRule: Remove content root entirely?

我的未来我决定 提交于 2019-12-23 04:26:08

问题


I an trying to shorten an URL like this:

www.mystore.com/webapp/wcs/stores/servlet/CategoryDisplay?langId=-1& storeId=10001&catalogId=10001&categoryId=10006

...to this:

www.mystore.com/CategoryDisplay?langId=-1&storeId=10001&catalogId=10001& categoryId=10006

Using the examples from IBM I can easily get rid of most of the URL simply by doing this in the Apache configuration:

RewriteRule ^shop/(.*) /webapp/wcs/stores/servlet/$1

And then adding this to the wc-server.xml file:

<context-root-rewrite value=“/shop” />

Is it possible to get rid of the /shop/ prefix entirely? It seems that nothing in Apache (aka IIS) prevents this, but will Websphere Commerce choke on it?


回答1:


Just put

httpd.conf:

 RewriteRule ^/(?!wcsstore)(.*) /webapp/wcs/stores/servlet/$1 [PT,L]

wc-server.xml:

  <SEOConfiguration defaultUrl=""
                    dynamicUrl="true"
                    enable="true">
      <context-root-rewrite value="/" />
  </SEOConfiguration>

Restart the server1 and http server.




回答2:


Answer: Because in this case we are just rerouting the requests for the servlet. If there's any other content there will be confusion. We are basically moving a sub-branch to be a sub-branch of the root, but there are other sub-branches.



来源:https://stackoverflow.com/questions/15356244/shortening-the-url-with-rewriterule-remove-content-root-entirely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!