1

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)

Saikat
  • 14,222
  • 20
  • 104
  • 125
user3307827
  • 556
  • 1
  • 7
  • 20

3 Answers3

0
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

Ankit Pise
  • 1,243
  • 11
  • 30
  • thanks for the answer.... but non of method do not work. I enabled mod_rewrite and .htaccess before...and active all native joomla sef. RewriteEngine On RewriteRule ^([^/]*)$ /archives.html?option=com_archive&date=$1 [L] (I wana send a parameter from homepage to archives.html page.) but I get a 500 error for all pages!(include home page) – user3307827 Feb 17 '14 at 06:41
  • [Link Here](http://docs.joomla.org/How_to_check_if_mod_rewrite_is_enabled_on_your_server) <- Check this url and check if mod rewrite is enabled – Ankit Pise Feb 17 '14 at 07:11
  • [Joomla 500 Internal Error](http://www.joomace.net/support/docs/acesef/faq/modifying-your-joomla-htaccess-file-500-internal-server-error) hope at least this will help you – Ankit Pise Feb 17 '14 at 07:34
0

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];
Banago
  • 1,350
  • 13
  • 22
0

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]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Try: `RewriteRule ^([^.]+\.html)/([0-9-]+)/?$ /$1?option=com_archive&date=$2 [L,NC,QSA,R]` as your first rule – anubhava Feb 17 '14 at 06:52
  • also I tried this: RewriteRule http://127.0.0.1/archives.html?option=com_archive&date=$2 [L,NC,QSA,R] ... no happen! – user3307827 Feb 17 '14 at 07:20
  • You have to make sure this is your very first URL in root .htaccess and the URL you should use is this: `http://127.0.0.1/archives.html/16-2-2014` for testing. – anubhava Feb 17 '14 at 07:35
  • thanks. your last code do not work...but I changed it to these: RewriteRule ^(archives\.html)/([0-9-]+)/?$ http://127.0.0.1/archives.html/?option=com_archives&date=$2 [L,NC,QSA] ...now it works...can u tell me why? – user3307827 Feb 17 '14 at 08:06
  • Ah I had one slash missing after `$1` see updated code. – anubhava Feb 17 '14 at 08:08