具有无扩展 URL 路由的相对 URL

发布于 2025-01-01 00:36:05 字数 298 浏览 4 评论 0原文

我对 URL 路由不熟悉,但我正在计划它的工作方式,以便我可以将 products.aspx?category=cars 这样的 URL 显示为 products/cars

我看到的最大问题是,如果在带有重新路由 URL 的页面上有指向 products.aspx?category=food 的链接,浏览器不会将用户发送到 products/cars/ products.aspx?category=food?

我错了还是有办法解决这个问题?

I new to URL routing, but I'm planning out how it will work so I can have a URL like products.aspx?category=cars appear as products/cars.

Biggest problem I can see happening is that if have a link to products.aspx?category=food on a page with a rerouted URL wouldn't the browser send the user to products/cars/products.aspx?category=food?

Am I wrong or is there a way to get around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白首有我共你 2025-01-08 00:36:05

它将发送到 products/cars/products.aspx?category=food,正确。

您可以通过在网址中添加前面的“/”来解决此问题,使其变为 /products.aspx?category=food

但是,如果您进行网址映射,您不想将链接构建为“产品/食品”,以便它们可以重写吗?

It will send it to products/cars/products.aspx?category=food, correct.

You can solve this by adding a preceeding '/' to your url so it becomes /products.aspx?category=food

However if you're URL mapping won't you want to build your links as "products/food" so that they can be rewritten?

偏爱你一生 2025-01-08 00:36:05

您所追求的是 URL 重写或友好 URL。这是一个可能对 ASP.NET 有帮助的链接我自己不使用 NET,所以不确定

http://www.codeproject.com/Articles/18318/URL-Mapping-URL-Rewriting-Search-Engine-Friendly-U

但这可能有帮助:
http://en.wikipedia.org/wiki/Rewrite_engine

What you are after is URL Rewriting or Friendly URLS. Heres a link that might help for ASP.NET I do not use NET myself so not sure

http://www.codeproject.com/Articles/18318/URL-Mapping-URL-Rewriting-Search-Engine-Friendly-U

But this might help:
http://en.wikipedia.org/wiki/Rewrite_engine

七颜 2025-01-08 00:36:05

通常,通过 URL 重写,您将始终使用 index.aspx。您的所有路径都将按照您建立的模式进行设置。

index.aspx?display=products&category=food

将变成

mysite.com/products/food
或者
mysite.com/products/category/food

您可以使用特定的重写工具通过配置选项自定义处理此问题的方式。

Typically, with URL rewriting, you are always going to be using index.aspx. All of your paths will be setup with a pattern you establish.

index.aspx?display=products&category=food

would turn into

mysite.com/products/food
or
mysite.com/products/category/food

You are able to customize how you handle this with configuration options with your particular rewriting tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文