Ok so i have a website and i want to change this url mywebsite.com/news1.php to mywebsite.com/news.php?id=news1
I am prety sure i need to do this with the Mod_Rewrite in the .htaccess file. But how?
Ok so i have a website and i want to change this url mywebsite.com/news1.php to mywebsite.com/news.php?id=news1
I am prety sure i need to do this with the Mod_Rewrite in the .htaccess file. But how?
To rewrite mywebsite.com/news1.php as mywebsite.com/news.php?id=news1, I suggest:
RewriteRule ^([a-z0-9]+).php$ news.php?id=$1
Please note, I have not included Options or RewriteEngine On -- only the rewrite rule. Edit your own code accordingly.
Just create .htaccess file and fill the following
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^news/([0-9]+)$ /news.php?id=$1 [QSA,L,NC]
I don't remember how to do this with .htaccess, but with php code is really simple:
Your news.php file:
<?php
$id = $_GET['id'];
if ($id){include($id.".php");}
?>