Welcome to WebmasterWorld Guest from 54.234.45.10

Forum Moderators: Ocean10000 & incrediBILL & phranque

Moving multiple files into another folder

all lower case with hyphens and numbers

     
6:31 pm on Nov 13, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1845
votes: 3


I had multiple files linked from one folder each with their own page.
like this:

example.com/folder/keyword1-keyword2/

I moved all those individual items onto a single page in the root. the old files had 2-4 words separated by hyphens and some with a number or letter on the end. they are all extensionless files and all lower case.

They are arranged like this

keyword1-keyword2/
keyword1-1letter/
keyword1-keyword2-number/
keyword1-keyword2-1letter/
keyword1-keyword2-keyword3-number/

I got this far writing the code for 2 keywords separated by hyphens but that's about all. Can someone help me with the rest of it?

RewriteRule ^folder1/[a-z]-[a-z]/$ http://www.example.com/page/ [R=301,L]
2:26 am on Nov 27, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2006
posts:2212
votes: 6


Check this:

RewriteRule ^folder1/[a-zA-Z0-9_.-]*$ http://www.example.com/page/ [R=301,L]


Please note that I come here to ask as well. I fund the above on the web. Keep in mind that this matches all in your folder. So, if you want to redirect just some pages, it'll catch everything in that subfolder.

You can play with the regex variations here:

[rubular.com...]

Cheers

P.S.
I just found this tool, so thanks for your question. :)
3:31 am on Nov 27, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11140
votes: 115


I got this far writing the code for 2 keywords separated by hyphens but that's about all. Can someone help me with the rest of it?

RewriteRule ^folder1/[a-z]-[a-z]/$ http://www.example.com/page/ [R=301,L]

that would only match two single alphabetic characters separated by a hyphen.

if i understand correctly, the pattern is 1-3 alphabetic strings, separated by hyphens, ending with an optional numeric string or single alphabetic character also separated by a hyphen.
i would try this:
RewriteRule ^folder1/[a-z]+((-[a-z])[1-2])?(-([a-z]|[0-9]+)?/$ http://www.example.com/page/ [R=301,L]


i suspect that pattern may produce some unwanted matches, but with a more precise description of your requirements and lucy24's knowledge of regular expressions you'll get the right answer sooner or later.
12:36 pm on Nov 29, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1845
votes: 3


@phranque

You are right about the pattern however what you wrote threw an internal server error. I only changed the the name of old folder in first line and domain name and name of new page in 2nd line.

Thanks for trying to help.
1:08 pm on Nov 29, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11140
votes: 115


threw an internal server error

what did the server error log show for that error?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members