在 html 扩展页面中传递变量。像 html?a=asdfadf
我想在 .html 扩展页面中传递变量,而 .html 页面是由 mod 重写组成的,因此这些不是 html 文件,而是通过 mod 重写制成的 .html 的 php 脚本。 有什么线索吗?
编辑:我的 .htaccess 文件*:
RewriteEngine on
RewriteRule ^watch/(.*)/(.*).html$ video.php?tag=$1&video=$2 [L]
RewriteRule ^(.*)/([0-9]+).html$ index.php?tag=$1&page=$2 [L]
RewriteRule ^(.*).html?([a-zA-Z=]+)$ index.php?tag=$1 [L]
* 如评论中提供的。间距可能与原始间距不同。
I want to pass variable in .html extension pages and .html pages are made up of mod rewrite so these are not html files but php script which are made .html through mod rewrite.
any clue?
EDIT: My .htaccess file*:
RewriteEngine on
RewriteRule ^watch/(.*)/(.*).html$ video.php?tag=$1&video=$2 [L]
RewriteRule ^(.*)/([0-9]+).html$ index.php?tag=$1&page=$2 [L]
RewriteRule ^(.*).html?([a-zA-Z=]+)$ index.php?tag=$1 [L]
* As supplied in the comments. Spacing may be different than the original.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加
[QSA]
标志到你的重写。这将获取原始查询字符串并向其中添加新参数。这会将
whatever.html?orderby=views
重写为index.php?tag=whatever&orderby=views
。唯一的问题是,无论如何使用 PHP,
whatever.html?tag=somethingelse
会给你带来一些奇怪的感觉。 ($_GET['tag']
将有两个值,但只有最后出现的那个才是真正的值。)但这通常没问题;你只需要确保不提供这样的 URL,并且你可以不关心尝试这些古怪 URL 的人会看到什么。 (当然,假设您正确验证了$_GET['tag']
。)Add the
[QSA]
flag to your rewrites. That will take the original query string and add your new params to it.This will rewrite
whatever.html?orderby=views
intoindex.php?tag=whatever&orderby=views
.The only catch is, with PHP anyway,
whatever.html?tag=somethingelse
will give you some weirdness. ($_GET['tag']
will have two values, but only the one that shows up last will be the real value.) But that's generally fine; you just have to be sure not to provide URLs like that, and you can just not care what people trying those wacky URLs see. (Assuming, of course, that you validate$_GET['tag']
properly.)