Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: phranque
[edited by: bill at 4:36 am (utc) on Jan 27, 2017]
[edit reason] use EXAMPLE.COM to prevent auto-linking [/edit]
Redirect uses prefix matching. If the prefix matches, then the redirect is invoked, but anything following the prefix is taken from the requested URL and added to the substitution. This is precisely what you are seeing.
Use RedirectMatch [httpd.apache.org] in mod_alias [httpd.apache.org], or use mod_rewrite [httpd.apache.org] whenever you need to "strip off" any part of a URL, or to change that part's position in the new URL.
I see this code
RedirectMatch (.*)\.gif$ [anotherserver.com$1.jpg...]
This replaces like-named gifs to jpgs. I do not have a clue as to the syntax needed to create a solution to my problem. How could I use RedirectMatch to match all files in a folder redirecting to a file?
I understand how redirect works but when it comes using (.*$ etc like as wildcards I have no idea! Can you provide any assistance?
RedirectMatch /somefolder\.html$ [anotherserver.com...]
Would this do the job? My understanding of this is that any time it matches a .html file in the folder "somefolder" it redirects the file to file.html.
I can't test it until a bit later on, so I am going to give it a go to see if it works.
Pretty much exactly what you had before, changing only the directive itself, and using regular-expressions syntax for the pattern:
RedirectMatch 301 ^/folder/ http://www.mydomain.co.uk/file.html
> ...when it comes using (.*$ etc like as wildcards I have no idea.
Here's a short Regular Expressions tutorial [etext.lib.virginia.edu].
Thanks also for that tutorial its really detailed and has helped me understand a bit more about regular expressions. Now I know a little bit more about them I can see where I was going wrong before. I just needed the solution to find out what the problem was :D