Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using a 301 redirect on my htaccess file. I was wondering if it's possible to redirect users only on their first access and then show the site normally with a rewrite condition or something similar.

thank you!

share|improve this question
    
What type of page are you trying to redirect that you only need to do it once? It this something that could better be done with PHP/ASP/etc? –  Andrew Lott May 20 '13 at 20:57
    
I need a 'welcome' page for the first user visit. –  lexolas May 21 '13 at 0:49

2 Answers 2

Based on your comment response, the best bet would be doing this in your page code instead of trying to use Apache to do it for you.

You could identify "new" users a couple of ways:

  1. Store IP addresses in a visitor's table.
  2. Drop a very simple cookie with a "visited" flag. This doesn't have to be used for any tracking or hold any identifiable information if you're concerned with privacy.

You can display your welcome page a couple of ways too:

  1. Redirect any visitors without the visitor's cookie to your welcome page. To avoid SEO problems you may want to only redirect human visitors and not bots (that "how" would be another topic best answered elsewhere).
  2. Add a section to your page layout that will only show for new visitors. This could be something like an expandable DIV at the bottom of a site-wide header section that gets called when the visitor's cookie isn't found, or even a welcome message within a lightbox, or anything else that's a bit more user-friendly than a hard redirect. This will give you the space for your welcome message and let the user close it away without having to take them away from the page where they've landed, which is probably where they wanted to be.

(It's worth noting that even if a user has cookies disabled, you should still be able to set a session so the welcome message doesn't appear on every page. The user may get it again on later visits, but if it's worked in the design well enough that shouldn't be a big deal.)

share|improve this answer
    
Header set Set-Cookie "visited=true" RewriteEngine On RewriteBase / RewriteCond %{HTTP_COOKIE} !^visited=true$ [NC] RewriteRule .? /welcome.html [R=301,NC,L] This still redirect all users! –  lexolas May 21 '13 at 13:03

There's no real good way to do this as you need to track users, and people more and more try to avoid that. If you insist, you could always set a cookie on the first visit then check for that cookie's existence afterwards.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.