-5

I need 1000 parked domains to redirect to a corresponding page.

For example, if one of the parked domains is "parkeddomain.com", then it must be redirected to http://example.com/landingpage/parkeddomain-com

Conditions:

  • Only the root URL of the parked domains must be redirected, not example.com
  • The browser url address must stay the same "parkeddomain.com"

The purpose is to create a simple system for a domain broker to host domains, each with one landing page per domain.

enter image description here

I will try to make this look less complicated, sorry. The idea is: redirect every domain to /landingpage/[thedomainname] except from the primary domain since that shows the homepage of the company website.

5
  • What do you mean exactly by "root URL of the parked domains must be redirected, not example.com"? What would the "not example.com" redirect be that you want to prevent? Why wouldn't a simple web server configuration with a virtual host for every domain work for this purpose? Oct 9, 2016 at 13:49
  • Thanks for your comment...I see that people are not happy with this question, propably because I didnt add my own coding effort, I'll try to add something to the question. About your comment: In my case the parked domains are coming and going on a regular basis, I sell and buy domains and have a landing pages on one and the same drupal website. So working with variables/wildcards in the rewriterules might work better than a large list of virtual hosts
    – Yuri
    Oct 9, 2016 at 15:14
  • So redirection of the root URL of the parked domains, i.e. "parked1.com" which is parked on top of the primary domain "example.com".
    – Yuri
    Oct 9, 2016 at 15:20
  • That still doesn't still answer the "not example.com" redirect question above. I can't understand what is the exact redirect you don't want to happen. Show some sample URLs in form: source.url -> destination.url which you want to happen and source.url -> destination.url which you do not want to happen. Oct 9, 2016 at 15:25
  • @TeroKilkanen I guess he doesn't want example.com get redirected to example.com/example-com - but I don't get what The browser url address must stay the same "parkeddomain.com" should tell me - I would really suggest using virtual hosts
    – msrd0
    Oct 9, 2016 at 16:45

1 Answer 1

1

Something like the following.

# Rewrite Request for parked domains '/' to landing page
RewriteCond %{HTTP_HOST} !=example.com
RewriteCond %{HTTP_HOST} (.+)\.(\w+)
RewriteRule ^/?$ /landingpage/%1-%2  [L]

To do it generically for a FQDN with two or more components would be more complex.

4
  • I tested this but it has not effect. I think that something else in my 'out of the box' Drupal 7 .htaccess file prevents this from working.
    – Yuri
    Oct 9, 2016 at 19:28
  • Then you'll need mod_rewrite logging to debug, or if you are using Apache v2.4 you can place this at the top of the Drupal htaccess file and change the [L] to [End], thouhg it might break if the request needs to be processed by Drupal itself.
    – Unbeliever
    Oct 9, 2016 at 19:52
  • Okay I found it: Drupal uses 'clean urls' but I still need to include the query string So this works: RewriteRule ^/?$ ?q=landingpage/%1-%2 [L]
    – Yuri
    Oct 9, 2016 at 21:08
  • Your rewrite rule works very well. The only issue I now have is that my server needs triple the amount of RAM when I have 2000 parked domains. Could that have to do with the fact that this rewrite rule eliminates Apache? The server uses Opcache and Memcache.
    – Yuri
    Jan 17, 2017 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .