Forum Moderators: phranque

Message Too Old, No Replies

Regex to Change Directory Name

         

jk3210

5:22 pm on Aug 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to use a regular expression to redirect urls containing "/mytheme2.5.1/" to the same url only with "/mytheme/". Example...

http://www.example.com/wp-content/themes/mytheme2.5.1/thumb.php?src=wp-content/woo_uploads/68-Wine250.jpg&w=250&h=180&zc=1&q=90

should redirect to...

http://www.example.com/wp-content/themes/mytheme/thumb.php?src=wp-content/woo_uploads/68-Wine250.jpg&w=250&h=180&zc=1&q=90

I tried numerous things and I thought for sure I had it with...

/mytheme2.5.1/(.*) => /mytheme/$1

...but no luck. Any ideas?

jdMorgan

12:34 pm on Aug 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> redirect urls containing "/mytheme2.5.1/" to the same url only with "/mytheme/".

In example.com/.htaccess:

RewriteRule ^wp-content/themes/mytheme2\.5\.1/(.+)$ http://www.example.com/wp-content/themes/mytheme/$1 [R=301,L]

This assumes that you already have other working mod_rewrite rules in that .htaccess file.

See this concurrent thread for additional (and important) information: [webmasterworld.com...]

Jim

jk3210

4:10 pm on Aug 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks very much, Jim.