简体   繁体   English

将/ blog /?(某物)重定向到/?(某物)

[英]RedirectMatch /blog/?(something) to /?(something)

I'm trying to redirect all requests which have "/blog/?" 我正在尝试重定向所有具有“ / blog /?”的请求 to "/?..." and use the following in my .htaccess: 到“ /?...”并在我的.htaccess中使用以下命令:

RedirectMatch 302 /blog/?(.*) http://www.example.com/?$1

but when I check it, 但是当我检查时

/blog/?p=28  -> www.example.com/?

so the rest is truncated. 因此其余部分将被截断。

p/s/ I don't want to redirect /blog/(something) to example.com/(something) ! p / s /我不想将/ blog /(something)重定向到example.com/(something)!

p/p/s/ I have a wordpress installed, if that might matter. p / p / s /如果有可能,我已安装了wordpress。 And I need to do that kind of stuff because I changed my wordpress folder to root and use /blog/ to show recent posts 我需要执行此类操作,因为我将wordpress文件夹更改为root并使用/ blog /来显示最新帖子

try this code .htacess 试试这个代码.htacess

Options +FollowSymLinks

RewriteEngine On

#RewriteBase /





RewriteRule ^ProductView-(.*).html product.php?page=$1



RewriteRule ^Home.html index.php

put your file name like this and change enter code here 这样enter code here文件名,然后enter code here更改enter code here

Use this code in your .htaccess to achieve that: 在您的.htaccess中使用此代码可实现以下目的:

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{QUERY_STRING} !^$
RewriteRule ^blog/?$ / [R=301,L,QSA]

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

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