質問

I want that domain.tld/en/ is a 100% mirror for domain.tld/ with all its (sub-)directories and files but does not change its URL for the client. Currently the PHP files can't access all their needed files (like CSS) because they can't find them in domain.tld/en/css/file.css (just in /css/file.css which should be the same)

This is what my .htaccess looks like right now (adapted from another question (see below)):

RewriteEngine On 
RewriteRule /en/(.*) /$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

Background

I can't find a solution for my problem on stackoverflow. Its very near to this question Redirect from one directory to another with mod_rewrite, but because I don't really understand how to modify htaccess files it doesn't help me, sadly.

I have a website running in the index.php of a main directory e.g. domain.tld/index.php, now I have modified the php file with replaceable strings for multilingual content and a detection in which directory its used in.

役に立ちましたか?

解決

There should not be any difference between files in the root directory and files in other directories. try this one (note that I've added L flag which will make the mod_rewrite stop looking for other rules when the first one was matched (in your case any file under en/ should have match both the first and the second rules - so it would apply both rewrites

RewriteEngine On
RewriteRule ^\/?en\/(.*) $1?lang=en [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top