Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

.htaccess

General discussions related to php

Moderators: macek, egami, gesf

.htaccess

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
<?php
if (isset($_GET['username']) === true && empty($_GET['username']) === false) {
  $username = $_GET['username'];
 
  echo $username;
} else {
  header('Location: index.php');
  exit();
}
?>

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
:help:
User avatar
gjeric
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Nov 22, 2012 5:27 am
Location: netizen

Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron