.htaccess基于index.php页面将不存在的页面重定向到index.php,该页面后面带有通配符和其他内容
请帮助,一些网站在我的主页上随意添加动态查询字符串 例如,我的主页是www.mysite.com/index.php,它们链接到许多类似以下的链接:.htaccess基于index.php页面将不存在的页面重定向到index.php,该页面后面带有通配符和其他内容,.htaccess,redirect,wildcard,.htaccess,Redirect,Wildcard,请帮助,一些网站在我的主页上随意添加动态查询字符串 例如,我的主页是www.mysite.com/index.php,它们链接到许多类似以下的链接: www.mysite.com/index.php?a=something-something-something www.mysite.com/index.php?a=something-other www.mysite.com/index.php?a=some-other-thing 这些链接在我的网站上打开,每个页面的内容都是相同的,就像我原
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
这些链接在我的网站上打开,每个页面的内容都是相同的,就像我原来的www.mysite.com/index.php一样
有几百个链接指向我的网站。那么我如何重定向这个:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
...
到
www.mysite.com/index.php
或直接访问www.mysite.com/
这是我目前在.htaccess文件中尝试的
RedirectMatch 302 ^index.php?a= http://www.www.example-ste.com/
RewriteRule ^/index.php?a=(.*) http://www.example-ste.com/
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
#if the query string has a pagewanted parameter
RewriteCond %{QUERY_STRING} (^|&)pagewanted=all [NC]
#Redirect and remove query string parameters for html pages
RewriteRule (.+\.html) http://www.mysite.com/$1? [R=301,L]
但网站上的页面仍在打开
另一个类似的问题。 如何将以“?pagewanted=all”结尾的页面重定向到同一页面,但不包含“”?pagewanted=all” 例如,我需要重定向页面: www.mysite.com/something/something.html?pagewanted=all 到 www.mysite.com/something/something.html
你好 我只是注意到了一些事情。我需要URL重定向规则,该规则将重定向页面,如:
www.mysite.com/index.php?a=something-something-something
www.mysite.com/index.php?a=something-other
www.mysite.com/index.php?a=some-other-thing
到站点的主页,根目录。你给了我这个密码:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
我必须说它工作得很好,但我注意到它以某种方式阻止或重定向所有包含?a=
的链接,例如在一些临时页面上,我有如下链接:
i.php?a=something-something-something
那么,您能否仅为基于index.php的页面采用代码,如:
www.mysite.com/index.php?a=something-something-something
不适用于以下链接:
i.php?a=something-something-something
如果我是对的,它可以在所有带有“
a=
”的链接上运行,但我只需要“index.php?a=
”尝试将以下内容添加到.htaccess文件的顶部
RedirectMatch 302 ^index.php?a= http://www.www.example-ste.com/
RewriteRule ^/index.php?a=(.*) http://www.example-ste.com/
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
#if the query string has a pagewanted parameter
RewriteCond %{QUERY_STRING} (^|&)pagewanted=all [NC]
#Redirect and remove query string parameters for html pages
RewriteRule (.+\.html) http://www.mysite.com/$1? [R=301,L]
编辑。
添加了要删除的规则
pagewanted=all
请尝试将folloginw添加到.htaccess文件的顶部
RedirectMatch 302 ^index.php?a= http://www.www.example-ste.com/
RewriteRule ^/index.php?a=(.*) http://www.example-ste.com/
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.mysite.com/? [R=301,L]
#if the query string has a pagewanted parameter
RewriteCond %{QUERY_STRING} (^|&)pagewanted=all [NC]
#Redirect and remove query string parameters for html pages
RewriteRule (.+\.html) http://www.mysite.com/$1? [R=301,L]
编辑。
添加了删除规则
pagewanted=all
是否有人对此有任何解决方案?是否有人对此有任何解决方案?如果有效,请单击答案左侧的勾号,将答案标记为已接受。如果有效,请单击答案左侧的勾号,将答案标记为已接受。