I am working on a website with multi-language support. The URLs are in the format:
https://example.com/gb/en/
https://example.com/fr/fr/
gb refers to the country, en refers to the language. The .htaccess file handles these variables and loads the language specific data from a file.
I am trying to duplicate this site in a subfolder, and have it working completely seperately to the original site.
https://example.com/promo/gb/en/
https://example.com/promo/fr/fr/
My .htaccess file looks like this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
ErrorDocument 404 /404.php
#force https
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteRule \.js$ /sprocketize.php [QSA,L,NC]
RewriteRule ^(admin) - [L,NC]
RewriteRule ^(app) - [L,NC]
RewriteRule ^(ws) - [L,NC]
RewriteRule ^(opia) - [L,NC]
RewriteRule ^promo-select(/)?$ /promo-select.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteRule ^([a-z]{2})/(.+)/$ http://%{HTTP_HOST}/$1/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2})/([a-z]{2})(?:/(.*)|)$ /$1/$3?lang=$2 [NC,QSA,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2})(?:/(.*)|)$ /$2?country=$1 [NC,QSA,PT]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f
RewriteRule ^([^/]+)/(.*)$ /$2?keyword=$1 [NC,QSA,PT]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /$1.php [NC,QSA]
I’ve tried changing
RewriteRule ^([^/]+)/(.*)$ /$2?keyword=$1 [NC,QSA,PT]
to
RewriteRule ^promo/([^/]+)/(.*)$ /promo/$2?keyword=$1 [NC,QSA,PT]
etc., but it’s either loading the original site or showing a ‘page not found’ error. I’ve also tried adding RewriteBase /promo but it just loaded the main site. I suspect I’m doing something obvious/stupid wrong. Thanks.
UPDATE
I should have said, the files in the subfolder are the same as the root folder, including the .htaccess file. There are 2 .htaccess files, 1 in the root, 1 in the subfolder. I’ve been editing the one in the subfolder.
Important
While working with .htaccess is usually important to clear browser cache after editing the file. I’ve had some problems with this
Have you tried to rewrite urls to your folder?
Notice the trailing ‘/’ and this, I think, should be on top
I use this and it works with my server…
Please try this and tell us what happens:
1. Change
to:
If above don’t work, try:
Change
to: