繁体   English   中英

apache 将 static url 重写为动态

[英]apache rewrite static url to dynamic

我正在尝试重写我的 url

http://www.domain.com/live/randomword

它应该 go 重写为

http://www.domain.com/live/?cat=randomword

这是我的测试:

RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1

我在 htaccess 文件中的所有内容是:

RewriteEngine on

您应该尝试在您的 .htaccess 中添加一个RewriteBase /并在您的规则后缀一个 [L] 来表示它是最后一个以类似结尾的重写规则:

RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]

如果这仍然不起作用,请务必检查 mod_rewrite 是否已启用

您也可以使用 [R,L] 而不是 [L] 来查看 url 中的重定向,因此可以了解更多信息。

希望这有帮助

在 .htaccess 文件中有此代码:

Options -MultiViews +FollowSymLinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]

在重写规则中缺少文件名或扩展名?

像这样写规则,

重写规则 ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM