Patrick S.
Seasoned Veteran
Here is something cool for every one out there.
My tutorial on How to use .htaccess rewrite.
What it does is you have a file say test.php?user=glock you want it to say /my-profile-glock with out having to create a directory for every profile.
First create a test file.
test.php
Put this in it
Now open .htaccess file(it's a hidden file) if you can't see it even if you can see hidden files you need to create on.
Put this in it:
You probably know what the PHP does so I will only explain the htaccess
First RewriteEngine On
Means .htaccess knows it can rewrite the url
second RewriteRule
Put that so it knows to rewrite only that file
^ starts the rewrite and $ ends it
([^/]*) this is for the profile name is it does what ever profile you want.
you can add more like this:
my-date-([^/]*)-([^/]*)-([^/]*)
now for this:
/test.php?user=$1
first off the $1 is the profile name in the PHP to add more just do
/test.php?user=$1&something=$2&something=$3
Basically like that
any questions? Just ask me in the tread 😉 Good luck
My tutorial on How to use .htaccess rewrite.
What it does is you have a file say test.php?user=glock you want it to say /my-profile-glock with out having to create a directory for every profile.
First create a test file.
test.php
Put this in it
Code:
<?php
$user = $_GET['user'];
if (isset($_GET['user'])) {
echo "Hello $user";
}else{
echo "Get out of here";
};
?>
Now open .htaccess file(it's a hidden file) if you can't see it even if you can see hidden files you need to create on.
Put this in it:
Code:
RewriteEngine On
RewriteRule ^my-profile-([^/]*)$ /test.php?user=$1 [L]
You probably know what the PHP does so I will only explain the htaccess
First RewriteEngine On
Means .htaccess knows it can rewrite the url
second RewriteRule
Put that so it knows to rewrite only that file
^ starts the rewrite and $ ends it
([^/]*) this is for the profile name is it does what ever profile you want.
you can add more like this:
my-date-([^/]*)-([^/]*)-([^/]*)
now for this:
/test.php?user=$1
first off the $1 is the profile name in the PHP to add more just do
/test.php?user=$1&something=$2&something=$3
Basically like that
any questions? Just ask me in the tread 😉 Good luck







