使用 URL 重写无效删除查询参数

Remove query param with URL Rewriting not working

我正在尝试用包含的参数重写 URL,如下所示:https://mywebsite/FOF/news/page/page1.php?name=petter&country=usa

我认为它不像 url 那样美观,我希望它看起来更像这样:

https:///mywebsite/spiderman

实际上重写工作并给我这个结果 https:///mywebsite/spiderman?name=petter&country=usa 直到 https://mywebsite/spiderman

这是我的重定向规则

##Enabling FollowSymlinks and disabling MultiViews options here.
Options +FollowSymlinks -MultiViews
##Setting rewrite base to / here.
RewriteBase /
RewriteEngine on
##Rewriting for page1 uri here.
RewriteRule ^page1$ page1.php    
##External redirect rules here.
RewriteCond %{THE_REQUEST} \s/FOF/news/page/page1\.php\s [NC]
RewriteRule ^ /customPage? [R=301,L]

##Internal rewrite rules here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customPage/?$ FOF/news/page/page1.php [L,NC]

如果有人可以帮助我

用你展示的样品,尝试;请尝试遵循 htaccess 规则。其中 customPage 是您要在浏览器上重定向的页面(您显示的问题中的蜘蛛侠)。根据您显示的示例,这是针对特定页面请求的。

确保在测试您的 URL 之前清除您的浏览器缓存。

##Enabling FollowSymlinks and disabling MultiViews options here.
Options +FollowSymlinks -MultiViews
##Setting rewrite base to / here.
RewriteBase /
RewriteEngine on
##Rewriting for page1 uri here.
RewriteRule ^page1$ page1.php    
##External redirect rules here.
RewriteCond %{THE_REQUEST} \s/FOF/news/page/page1\.php\?name=(?:[^&]*)&country=(?:\S+)\s [NC]
RewriteRule ^ /customPage? [R=301,L]

##Internal rewrite rules here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customPage/?$ FOF/news/page/page1.php?name=petter&country=usa  [L,NC,QSA]