0

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?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

3 Answers3

1

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.

showdev
  • 28,454
  • 37
  • 55
  • 73
0

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]
0

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");}
?>
Artur Couto
  • 498
  • 1
  • 6
  • 19