0

I have a problem with my .htacces

I have set $base_url() from my db.php connection like this

<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'root');
define('DB_DATABASE', 'wall3');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
mysql_query ("set character_set_results='utf8'");   
$path = "uploads/";
$profile_path="user_profile_uploads/";

$perpage=10; // Updates perpage

$base_url='http://www.ecoshoptr.com/';
$gravatar=0; // 0 false 1 true gravatar image
$rowsPerPage=10; //friends list
?>

The problem is $base_url does routing. For example: When i click the user profile image from like this image:

enter image description here

Does not direct me to the user profile.

However, URLs to open the user's url. If you look at the second picture you can see the opened pages is index.php page, but the url address URLs users

enter image description here

This is my .htaccess inside:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^ecoshoptr\.com$
RewriteCond %{REQUEST_URI} !^/$1
RewriteRule (.*) http://www.ecoshoptr.com/$1 [r=301,nc]


RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?id=$1

<div id='header'>
<img src='<?php echo $base_url;?>wall_icons/blacklogo.png'/>
<span style='float:right'>
<ul id='nav'>
<?php if($login) { ?>
<li><a href="<?php echo $index_url; ?>">Home</a></li>
<li><a href="<?php echo $base_url.$session_username; ?>">Profile</a></li>
<li><a href="<?php echo $base_url.'friends/'.$session_username; ?>">Friends</a></li>
<li>
<?php if($session_conversation_count>0) {
echo "<span id='conversation_count'>$session_conversation_count</span>";
} ?>
<a href="<?php echo $base_url.'messages.php'; ?>">Messages</a></li>
<li><a href="<?php echo $base_url.'settings.php'; ?>">Setting</a></li>
<li><a href="<?php echo $base_url.'logout.php'; ?>">Logout</a></li>
<?php } else { ?> 
<li><a href="<?php echo $index_url; ?>">Login</a></li>
<li><a href="<?php echo $index_url; ?>">Sign Up</a></li>        
<?php   } ?>
</ul>
</span>
</div>

Home, settings, logout button is working but other buttons is not working.

How do I solve this problem Can you help me thanks!

Cosmos
  • 337
  • 1
  • 3
  • 13

2 Answers2

1

Try to use this htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./profile.php?username=$1 [L]
somebodyknowsme
  • 416
  • 2
  • 8
0

Try this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
  • What included your index.php? –  Apr 29 '14 at 15:13
  • Your .htaccess file is absolutely wrong. You must to separate the php, html code and the rewrite commands. Check this: http://stackoverflow.com/questions/13170819/what-is-htaccess-file-in-php And before ask a question, please use the search function. –  Apr 29 '14 at 15:30