简体   繁体   中英

301 Redirect with Wordpress?

the following Redirect is not working, but why is the second one working when I place this before the Wordpress code in the .htaccess file?

Not working:

RewriteEngine On
RewriteRule ^/euro/stadien/saint-etienne/$ /stadien/saint-etienne/? [R=301,L]

Working:

Redirect 301 /euro/stadien/saint-etienne/ /stadien/saint-etienne/

Do I need to add something like the following to the first piece of code?

RewriteBase /
RewriteCond

Anybody knows the solution?

You can use:

RewriteEngine On
RewriteRule ^euro/stadien/(saint-etienne)/$ /stadien/$1/? [R=301,L,NC]
  • Leading slash is not matched in mod_rewrite rules while in .htaccess
  • Optionally you can capture last part and reuse in target as shown above.

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