how to Change a GET method URL to clean URL in php?

1.3k Views Asked by At

This is an URL that created by GET method in php to send DATA parameter to archives.html page:

http://127.0.0.1/archives.html?option=com_archive&date=16-2-2014

Is there any way to clean this URL?

I want to do something like this (and I can send parameter too!)

http://127.0.0.1/archives.html/16-2-2014

Can I do that by mod_rewrite?

(I am developing a component on joomla3)

3

There are 3 best solutions below

5
On BEST ANSWER

You can use this rule in your root .htaccess:

RewriteEngine On

RewriteRule ^(archives\.html)/([0-9-]+)/?$ /$1/?option=com_archive&date=$2 [L,NC,QSA]
3
On
RewriteEngine On
RewriteRule ^([^/]*)$ /archives.html?option=com_archive&date=$1 [L]

This htaccess would do this job for you by url i assume this is joomla

this doc might help you

http://docs.joomla.org/Enabling_Search_Engine_Friendly_(SEF)_URLs_on_Apache

1
On

One way to do this in PHP:

$original_url = 'http://127.0.0.1/archives.html?option=com_archive&date=16-2-2014';
$new_url = explode('?', $original_url);
$clean_url = $new_url[0];