Htaccess redirect on first access

.htaccessredirect

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!

Best Answer

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.)