Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using plogger with wordpress and I'm in the process of moving current photos to new directories. I need to setup a permanent redirect once I change the directory

For example.

Current location: www.mysite.com/products/cakes/birthday/batman-cake.html

New location: www.mysite.com/products/cakes/superhero/batman-cake.html

So if someone types in the current location it should redirect to the new location.

I have 2 .htaccess files. One in the root directory and one in the Plogger directory. the plogger one I assume is used to make the urls pretty and I think this is where I need to make the changes. Also I only want to redirect individual pages and not the entire directory

See the plogger .htaccess below.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /products
  RewriteCond %{REQUEST_URI} !(\.|/$)
  RewriteRule ^.*$ http://www.mysite.com%{REQUEST_URI}/ [R=301,L]
  RewriteCond %{HTTP_HOST} !^www [NC]
  RewriteRule ^(.*)$ http://www.mysite.com/products/$1 [R=301,L]
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^.*$ - [S=2]
  RewriteRule feed/$ plog-rss.php?path=%{REQUEST_URI} [L]
  RewriteRule ^.*$ index.php?path=%{REQUEST_URI} [L]
</IfModule>

Please note that someone set this up for me a while ago and I'm not a programmer but I'm a little technical.

Any help would be appreciated.

Thanks

share|improve this question
add comment

migrated from stackoverflow.com Apr 24 '11 at 17:04

This question came from our site for professional and enthusiast programmers.

1 Answer

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteRule ^products/cakes/birthday/batman-cake.html$ /products/cakes/superhero/batman-cake.html [R=301,L]

  RewriteBase /products
  RewriteCond %{REQUEST_URI} !(\.|/$)
  RewriteRule ^.*$ http://www.mysite.com%{REQUEST_URI}/ [R=301,L]
  RewriteCond %{HTTP_HOST} !^www [NC]
  RewriteRule ^(.*)$ http://www.mysite.com/products/$1 [R=301,L]
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^.*$ - [S=2]
  RewriteRule feed/$ plog-rss.php?path=%{REQUEST_URI} [L]
  RewriteRule ^.*$ index.php?path=%{REQUEST_URI} [L]
</IfModule>
share|improve this answer
    
I tried this but I always get a 404 page not found. There must be something missing here. The closest I can get to making this work for me is modifying the .htaccess file under the root directory as follows: Redirect 301 /products/cakes/birthday/batman-cake.html products/cakes/superhero/batman-cake.html? The problem here is that I must put the trailing "?" question mark and this Always shows up in the URL. Any other suggestions? –  procon Apr 24 '11 at 19:23
    
missed the trailing $ –  Mike Apr 24 '11 at 22:08
    
Still no luck, just getting the 404 page. Any way to debug what is happening behind the scenes on my godaddy account? –  procon Apr 25 '11 at 3:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.