简体   繁体   中英

wordpress: htaccess redirect url

I want to edit Wordpress 3.5 .htaccess file to define some url redirect rules eg:

Redirect http://localhost/my_site/blog/cat/hello-world to http://localhost/my_site/cat/hello-world

I tried

Redirect 301 /localhost/my_site/blog/cat/hello-world/ http://localhost/my_site/hello-world/

and also

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my_site/

Redirect 301 http://localhost/my_site/blog/cat/hello-world/ http://localhost/my_site/cat/hello-world/

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my_site/index.php [L]
</IfModule>

but browser says

Page Not Found

This is somewhat embarrassing, isn't it?

any idea.. how can i do this..?

You don't want to use Redirect in conjunction with mod_rewrite, just stick with mod_rewrite. Replace the Redirect with:

RewriteRule ^my_site/blog/cat/hello-world/ /my_site/cat/hello-world/ [L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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