How can I create friendly URLs with .htaccess?

In the document root for http://website.com/ I’d put an htaccess file like this: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> Then in your PHP script you can manipulate the $_GET[‘url’] variable as you please: $path_components = explode(“https://stackoverflow.com/”, $_GET[‘url’]); $ctrl=$path_components[0]; $id=$path_components[1]; $tab=$path_components[2];

URL rewriting with PHP

You can essentially do this 2 ways: The .htaccess route with mod_rewrite Add a file called .htaccess in your root folder, and add something like this: RewriteEngine on RewriteRule ^/?Some-text-goes-here/([0-9]+)$ /picture.php?id=$1 This will tell Apache to enable mod_rewrite for this folder, and if it gets asked a URL matching the regular expression it rewrites it … Read more

URL rewrite with .htaccess for wildcard domain

Try putting some rewrite rules like this in your .htaccess file: RewriteEngine on RewriteBase / # Make sure it’s not an actual file or # directory, being accessed. If you wish. #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d # Match the subdomain RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ # Rewrite the request to the main domain: … Read more