General discussions related to php

Moderators: macek, egami, gesf

User avatar
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Nov 22, 2012 5:27 am
Location: netizen


Postby gjeric » Mon Dec 03, 2012 5:25 pm

hi to all,
i have a script named profile.php which will be a template for users info. so i post a basic template of it:

Code: Select all

if (isset($_GET['username']) === true && empty($_GET['username']) === false) {
  $username = $_GET['username'];
  echo $username;
} else {
  header('Location: index.php');

hmm so if i write in URL for example: http://localhost/profile.php?username=test it echo in a browser name: test.
so i would like to short this URL to: http://localhost/test and for this i would like to use an .htaccess file. i was looking for something with no success! but i thing the .htaccess file shoul be something in this way:

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /profile.php?username=$1

don't work! so any clue? plese help

Return to “PHP General”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests