Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect with wildcard

         

jmueller0823

2:24 am on Mar 30, 2010 (gmt 0)

10+ Year Member



We have a bunch of files located in our root named like this:
http://www.example.com/special*.htm

All of those "special*" files need to be redirected back to our home page.
Like this: http://www.example.com/special*.htm >> http://www.example.com/

QUESTION
How would we write that redirect in the htaccess?

Thanks much.

(Yes, I know the answer is already here somewhere. I looked and couldn't find.)

[edited by: jdMorgan at 7:19 pm (utc) on Apr 1, 2010]
[edit reason] example.com [/edit]

g1smd

6:07 am on Mar 30, 2010 (gmt 0)

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



Probably 60 000 of the 68 000 threads in this forum contain code related to the single line you'll need to add to the .htaccess file.

It'll be a RewriteRule. You'll need the [R=301,L] flags. That pattern will need to match the ^start of the URL request and capture the rest in a backreference (.*) for use as $1 in the target. Being a redirect, the target will also contain the domain name.

jmueller0823

1:05 pm on Mar 30, 2010 (gmt 0)

10+ Year Member



Thanks.

As I said: ((Yes, I know the answer is already here somewhere. I looked and couldn't find.))

Could you lay out the code for me?
I'd appreciate it. Thanks.

jdMorgan

5:24 pm on Mar 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Could you lay out the code for me?

That is not beneficial to the community, as it would essentially end the discussion. Our forum Charter states that we focus on discussion and education, and not on an unsustainable "free consulting service" model.

We can help you fix your code, though, because that generates discussion.

This search (and variants using synonyms) may help you get started: redirect subdirectory home page rewriterule [google.com]

Please see also the resources cited in our Apache Forum Charter, and the thread in our Apache Forum Library.

Thanks,
Jim

jmueller0823

7:01 pm on Apr 1, 2010 (gmt 0)

10+ Year Member



Jim
Help me understand...

Providing the solution would "end the discussion", which is not good...

You'd rather continue this Q&A, while I struggle with the solution so that the discussion stays open?

Doesn't sound right.

Thanks.
Jim

jdMorgan

7:18 pm on Apr 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Our Forum Charter [webmasterworld.com] explains the purpose, goals, and methods of this forum in some detail.

The search cited above should help get you started, if entered into the "site search" facilty -- See link at the top of this page.

We cannot sustain a "free code-writing service" or "help desk"-type service here, as we have very few contributors and far too many requests for an all-volunteer forum to support. However, we will be happy to help you get your own code working, or to answer specific questions.

Jim

jmueller0823

8:35 pm on Apr 1, 2010 (gmt 0)

10+ Year Member



Jim, thank you.

I don't see the ability to PM you...

[edited by: jdMorgan at 1:02 am (utc) on Apr 2, 2010]
[edit reason] TOS #20 [/edit]

jdMorgan

1:03 am on Apr 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"PM" is available as the "Sticky Mail" icon below each poster's name and icon.

Jim