【问题标题】:how can i rewrite my url htacceess with GET我如何用 GET 重写我的 url htaccess
【发布时间】:2021-08-26 13:04:25
【问题描述】:

我在重写我的 url 时遇到问题,如何在下面重写这个 url:

http://localhost/Car/index.php?page=allCars&numpage=2

这是用于测试的php和html代码

标签: .htaccess redirect mod-rewrite url-rewriting friendly-url


【解决方案1】:

使用您显示的示例,请尝试遵循 htaccess 规则文件。请确保在测试您的 URL 之前清除您的浏览器缓存。这些规则假定您的 htaccess 存在于 Car 文件夹/目录中。

Options All -Indexes -Multiviews
RewriteEngine On 
RewriteBase /Car/
RewriteRule ^([-a-zA-Z0-9]+)/?$ index.php?page=$1 [QSA,L]
##External rewrite rule.
RewriteCond %{THE_REQUEST} \s/index\.php\?page=([^&]*)&numpage=(\d+)\s [NC]
RewriteRule ^ /Car/%1/%2? [R=301,L]
##Internal rewrite rule.
RewriteRule ^([^/]*)/([^/]*)/?$ Car/index.php?page=$1&numpage=$2 [L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-30
    • 1970-01-01
    • 2014-05-16
    • 1970-01-01
    • 2016-07-23
    • 2016-10-13
    • 2011-05-07
    相关资源
    最近更新 更多