问题
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