Hi,
My Website directory structure
ABC
|_includes, documents,images,AR,index.php
|_top_menu.php, side_menu.php
under the ABC folder is sub folder with the main index.php. The AR (Arabic language folder) is under the same directory structure folder is like ABC but with Arabic content. In both directory have more than 20 folders with sub folders.
In top_menu.php and side_menu.php define the menu contents.
My question is that how can i use switch language folder without changing the directory structure?
PHP multilanguage directory
Moderator: General Moderators
Re: PHP multilanguage directory
You don't have any switching already in place?
With simpler solutions like this, often there's some sort of URL rewriting or virtualhost-based scheme to switch the "document root" to the desired location. Like if you used a subdomain, ar.example.com, you'd have a virtualhost pointing it to /ABC/AR. If you had a subdirectory in the URL, like www.example.com/ar, then it'd likely be URL rewriting to point all files towards /ABC/AR/* instead of the /ABC/* they originally were going to be.
With simpler solutions like this, often there's some sort of URL rewriting or virtualhost-based scheme to switch the "document root" to the desired location. Like if you used a subdomain, ar.example.com, you'd have a virtualhost pointing it to /ABC/AR. If you had a subdirectory in the URL, like www.example.com/ar, then it'd likely be URL rewriting to point all files towards /ABC/AR/* instead of the /ABC/* they originally were going to be.
-
salman1karim
- Forum Newbie
- Posts: 4
- Joined: Mon Oct 03, 2011 7:51 am
Re: PHP multilanguage directory
I didnt use switching?
I have same directory structure for English and Arabic content. But i don't know how can i use URL switcher between two languages.
I have same directory structure for English and Arabic content. But i don't know how can i use URL switcher between two languages.
-
salman1karim
- Forum Newbie
- Posts: 4
- Joined: Mon Oct 03, 2011 7:51 am
Re: PHP multilanguage directory
At last i resolve issue my self. May be this is helpful for anyone. If anyone want to use this code the directory structure should be same.
Now Just give the link
Code: Select all
<?php
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$parse = parse_url($pageURL);
$a=$parse['host'];
$c=basename($_SERVER['PHP_SELF']);
$b='http://' . $a . '/abc/ar/' . $c ;
?>
Code: Select all
echo '<a href="' . $b . '"><img src="http://abc/images/icon.png" style="float:right; padding-right:5px; border:0;" /></a>';