1

i would like to rewrite all my website's urls from this https://website.com/page.php?lang=2 to this https://website.com/en/page

(creating /en/ directory while hiding .php extension)

Can anyone help me with this one? Thank you in advance

MarcusV
  • 355
  • 3
  • 6
  • 19

1 Answers1

2

Try it like this,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/([\w-]+)$ $1.php?lang=2 [QSA,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
  • Although it seems to work, something is wrong about the relative paths to the css. The page is loading broken with the following errors in the console: "Resource interpreted as Stylesheet but transferred with MIME type text/htm"l and "Uncaught SyntaxError: Unexpected token <" – MarcusV Jan 09 '17 at 10:19
  • Try in your page where css is not loading, change your domain to actual domain name. – Abhishek Gurjar Jan 09 '17 at 10:20