0

Premise: I hate htaccess

I have to redirect or rewrite an URL: I want that this URL

http://www.example.com/en.php

become

http://www.example.com/en/

For example: clicking a link like <a href="en">English</a> I want that it navigates to the page en.php but showing the url http://www.example.com/en/

I've tried this, but doesn't work

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On
  RewriteRule ^/en/ http://www.example.com/en.php
</IfModule>
Fred K
  • 13,249
  • 14
  • 78
  • 103
  • First of all, have you enable mod_rewrite on your server? And allow overwrite in your virtualhost configuration? – 蒋艾伦 Jul 04 '13 at 09:21
  • If all configuration set, please check this post about how to omit .php in your url http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess – 蒋艾伦 Jul 04 '13 at 09:22
  • The leading / gets stripped off the URI to match, and the trailing / can be made optional: `^en/?$` – Phil Perry Dec 31 '13 at 17:47

2 Answers2

0

This solved:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase / 
  RewriteRule ^en en.php
</IfModule>
Fred K
  • 13,249
  • 14
  • 78
  • 103
0

try this

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^en/$ en.php
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82