Link to home
Start Free TrialLog in
Avatar of gplana
gplanaFlag for Spain

asked on

.htaccess RewriteRule doubt

Dear Expert:

I have xampp for Windos installed locally. I have a web site which is using URLs such as:

http://localhost/ad/index.php?option=com_are&view=listado&Itemid=17&lang=es

I want this URL look like:

http://localhost/ad/es/Barcelona

I have read something about .htaccess file and RewriteRule, so I have added this line to my actual .htaccess file to accomplish this:

RewriteRUle ^/ad/es/Barcelona$ /ad/index.php?option=com_are&view=listado&Itemid=17&lang=es [L]

After this, old URL is still working and new URL (/ad/es/Barcelona) doesn't work (it gets a 404: component not found).

What I'm doing wrong ?

Thank you.
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

If your rule is in a .htaccess file rather than the httpd.conf you need to remove the leading / e.g.

RewriteEngine On
RewriteBase /
RewriteRule ^ad/es/Barcelona$     /ad/index.php?option=com_are&view=listado&Itemid=17&lang=es [L]

Open in new window

Avatar of gplana

ASKER

Wow, it worked without the leading /

Can you tell me why I cannot put a leading / ?
ASKER CERTIFIED SOLUTION
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gplana

ASKER

Excellent. Thank you.