tags:

views:

26

answers:

1

hey,

my php:

if(isset($_GET['text'])) {
 $text = $_GET['text'];
} else {
 $text = "default"; //if no ?text= set then print "default"
}

my .htaccess

RewriteEngine On
RewriteRule ^(.*)$ index.php?text=$1 [L,QSA]

the .htaccess works actually fine, except if i don't set text to my url my else statement ("default") doesn't work.

so if enter mydomain.com/whatthe everything works fine ($text = "whatthe";) however when i just call mydomain.com $text is empty instead of cotaining "default".

what do i wrong?

+2  A: 

What is happening is that you are still setting the GET variable, albeit to null or an empty string.

You should use:

if(isset($_GET['text'] && !empty($_GET['text'])) {
Josh Stuart