繁体   English   中英

"htaccess 带参数的重定向 url"

[英]htaccess redirect url with parameters

我有数百个这样的链接:

http://www.domain.com/index.php?tag=value

除了重定向请求之外,您可能还需要确保新的url确实也起作用。 为此,您将需要外部重定向和内部重写。 在下面的示例中,我使用THE_REQUEST技巧仅在规则是实际请求URL时才触发规则,而不是在内部重写时触发。 需要防止无限循环。

#External redirect with THE_REQUEST trick; change R to R=301 when everything works correctly
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index\.php\?tag=(.*)\ HTTP
RewriteRule ^ /%2? [R,L]

#Internal rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?tag=$1 [L]

我有这样的链接: www.domain.com/en/Ads-3-Picardie-Aisne-Caravans-camper-cars-Demo03-Pro-Acc我想将链接重定向到(用大写字母“广告”改变世界'ads'): www.domain.com/en/ads-3-Picardie-Aisne-Caravans-camper-cars-Demo03-Pro-Acc而 - htaccess 是:

RewriteRule ^(fr|en|es|it)/Ads-([0-9]+)-[a-zA-Z0-9-]+$ ad_page.php?id_ad=$2&lang=$1 [L]
### Rewriting ulrs ads, shops and page whithout language ###
RewriteRule ^Ads-([0-9]+)-[a-zA-Z0-9-]+$ ad_page.php?id_ad=$1 [L] ```

Thank you.

暂无
暂无

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

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