I’m having a weird issue with mod_rewrite
. My website is set up in such a way that the user can access a translated version of the webpage via a URL like example.com/pt/about
or just access the normal page like so example.com/about
, to accomplish this I have the following in my .htaccess
:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(en|pt)/?$ index.php?lang=$1 [NC,QSA,L]
RewriteRule ^about/?$ about.php [NC,QSA,L]
RewriteRule ^contact/?$ contact.php [NC,QSA,L]
RewriteRule ^([A-Za-z]{2})/about/?$ about.php?lang=$1 [NC,QSA,L]
RewriteRule ^([A-Za-z]{2})/contact/?$ contact.php?lang=$1 [NC,QSA,L]
In my development machine I’m running XAMPP 3.2.2 with Apache 2.4.29 and in my production server I’m running Ubuntu 16.04.3 LTS with Apache 2.4.18. In my development machine everything works fine, if I try to visit /about
it shows me about.php
and if I try /pt/about
it translates the page to portuguese as is the correct behavior, but in the production server if I try to visit /about
I get a 404 error, but if I try to visit /pt/about
it displays the page correctly without any issues.
Why is this happening and how I might correct it?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!