3

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]
3
  • What server-side language are you using to process query strings and what is the default document name (e.g., index.php)?
    – dan
    Commented Dec 30, 2013 at 23:45
  • I'm using apache, and it's name is index.php
    – user34853
    Commented Dec 30, 2013 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
    Commented Dec 31, 2013 at 10:53

1 Answer 1

2

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.

11
  • Still getting a blank page.
    – user34853
    Commented Dec 30, 2013 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
    Commented Dec 30, 2013 at 23:58
  • I have mod_rewrite installed and enabled. But this still didn't work :/
    – user34853
    Commented Dec 31, 2013 at 0:12
  • Be sure to completely clear the cache in your browser. I assume the home page is not blank, correct?
    – dan
    Commented Dec 31, 2013 at 0:14
  • Still blank, I tried clearing cache too.
    – user34853
    Commented Dec 31, 2013 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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