views:

156

answers:

1
+2  Q: 

Remove part of URL

Hello,

i have a url like this http://example.com/blog/photos/photos/gallery/image/1.

And i need to remove the second photos folder. How do i remove the part using mod_rewrite and .htaccess?

For your interest /blog is my document root.

Thanks a lot for any suggestions, Steve

EDIT

You should know that the URLs being generated by Wordpress 3.0 und NextgenGallery.

http://example.com/blog is my document root. That means i have installed Wordpress into the folder blog.

The first slug after blog is the page i have my gallery associated with.

The second slug is the name of the album and could be renamed to everything you want. It is just a placeholder for my galleries. gallery is the name of the gallery.

+4  A: 

Assuming you want to do a redirect:

RewriteRule ^/blog/photos/photos/(.*)$ /blog/photos/$1 [R]
Taylor Leese
+1. BTW since I'm learning mod_rewrite what's '[R]' why didn't you use '[301,L]' permanent redirect?
Marco Demajo
R just stands for redirect. Look at all the options here to figure out what is correct for your scenario: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
Taylor Leese
Taylor,thank you for your fast response. But i really don't know if a simple redirect solves the problem. See my edit above please...Any further suggestions?Steve
gearsdigital
Why do you think it doesn't solve the problem? Your edit doesn't really explain what you think the problem is that clearly.
Taylor Leese
Taylor, you're right. I can't explain why it did not work but now it works. I'm pretty sure something went wrong with my cms configuration. Now everything is fine :) Thank you very much.
gearsdigital