简体   繁体   English

当我在 url 斜杠中有参数时,如何重定向到特殊页面?

[英]How can I redirect to a special page when I have parameters in url slashes?

For example, I want the users to be able to go to a tour using a link like this:例如,我希望用户能够使用这样的链接 go 进行游览:

page.com/tour/name

How can I make it, like redirecting to tour.html and then loading there the info using the name parameter in the URL?我怎样才能做到这一点,比如重定向到 tour.html,然后使用 URL 中的 name 参数加载信息? Using JS.使用 JS。

You can use this lines in the .htaccess file您可以在 .htaccess 文件中使用此行

RewriteEngine on
RewriteRule ^tour/([^/]+).php /page.php?search=$1 [NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 passport.js 在身份验证失败时会自行创建一个未经授权的页面? 我怎样才能将它重定向到一个特殊的页面? - Why does the passport.js create an Unauthorized page on its own when authentication fails? how can I redirect it to a special page? Beforeunload无法将用户重定向到另一个页面,如何在尝试关闭窗口/选项卡时将用户重定向到另一个页面/ URL? - Beforeunload is not working to redirect user to another page, how can I redirect user to another page/url when he attempts to close a window/tab? 有斜杠时重定向URL - Redirect URL when there are trailing slashes 如何使用 URL 参数重定向到页面? - How can I use an URL parameter to redirect to a page? 如何在页面重新加载或重复之前添加URL参数? - How can I add URL parameters before page reloads or duplicates? 如何在http.post url中传递像“#”,“^”这样的特殊字符作为参数 - How can i pass special character like “#”, “^” in http.post url as parameters 如何设置参数有多个斜杠的快速路由? - How do I set up an express route where parameters have multiple slashes? 如何将 url 重定向到另一个 url? - how can I redirect a url to another url? 文件更改时如何重定向服务器URL? - how i can redirect server url when file change? 检测到iFrame时如何重定向到另一个页面? - How can I redirect to another page when an iFrame is detected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM