Kerem Bekman
Kerem Bekman

Reputation: 1283

.htaccess with database

How can I do this that mydomain.com/ -> mydomain.com/profile.php?username=

Now You can start search via url like domain.com/

My htaccess file is

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=search&val=$1 [QSA,L]

I can understand in php file

$val = $_GET['val'];
if($c->userNameCheck($val))
{
    header("Location:".$url."/profile.php?username=".$val);
}

But I dont want to show profile.php

Upvotes: 0

Views: 337

Answers (1)

Michał Wojciechowski
Michał Wojciechowski

Reputation: 2490

You could simply replace the rule with:

RewriteRule ^(.*)$ profile.php?username=$1 [QSA,L]

However, since you won't be executing the index.php file, the userNameCheck method won't be called. I assume it does some sort of a check if the provided parameter is a valid username -- to make it run with the modified rule, you'd have to move that call to the profile.php file.

Upvotes: 1

Related Questions