I can't figure out how to make users visiting my website using links like: mysite.com/?ref=XXXXXXX see the homepage instead of a completely blank page. I tried using htaccess but I can't figure out how to do it.

This is how my .htaccess file looks like:

Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{QUERY_STRING} ^ref=(.+)$ [NC]

RewriteRule ^index.php http://mysite.com/? [L,R=301]
  • What server-side language are you using to process query strings and what is the default document name (e.g., index.php)? – dan Dec 30 '13 at 23:45
  • I'm using apache, and it's name is index.php – user34853 Dec 30 '13 at 23:46
  • (I realise you've solved this, but...) If you are accessing mysite.com/?ref=XXXXXXX then your RewriteRule ^index.php... is never going to match. – MrWhite Dec 31 '13 at 10:53

Try adding this to a .htaccess file in your document root:

Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{QUERY_STRING} ^ref=(.+)$ [NC]
RewriteRule ^index.php$ /? [L,R=301,NC]

Make sure you have the mod_rewrite module installed.

  • Still getting a blank page. – user34853 Dec 30 '13 at 23:56
  • Try this then: RewriteRule ^index.php http://mysite.com/? [L,R=301] Also be sure to check that mod_rewrite is installed and enabled in your httpd.conf – dan Dec 30 '13 at 23:58
  • I have mod_rewrite installed and enabled. But this still didn't work :/ – user34853 Dec 31 '13 at 0:12
  • Be sure to completely clear the cache in your browser. I assume the home page is not blank, correct? – dan Dec 31 '13 at 0:14
  • Still blank, I tried clearing cache too. – user34853 Dec 31 '13 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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