- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 PHP 中有一个多语言网站(西类牙语、英语、法语),主要语言是英语。
如果 $_SESSION['idm']
设置为“en”,它会加载包含翻译的文件。
我想这样设置:
如果用户语言是西类牙语
www.mydomain.com
和 mydomain.com
-> es.mydomain.com
www.mydomain.com/video.php?id=3
-> es.mydomain.com/video.php?id=3
如果用户语言是法语
www.mydomain.com 和 mydomain.com
-> fr.mydomain.com
www.mydomain.com/video.php?id=3
-> fr.mydomain.com/video.php?id=3
如果不是以上任何一个
www.mydomain.com 和 mydomain.com
-> en.mydomain.com
www.mydomain.com/video.php?id=3
-> en.mydomain.com/video.php?id=3
我该怎么做,这样的 SEO 是否明智?
最佳答案
在 PHP 中:
// check if the current domain is the generic one
$req_domain = $_SERVER['SERVER_NAME'];
if ($req_domain == 'www.mydomain.com' || $req_domain == 'mydomain.com') {
$subdomains = array ('fr' => 'fr.mydomain.com',
'es' => 'es.mydomain.com',
'en' => 'en.mydomain.com');
// get the language from the session variable (if set), or use default
$lang = 'en'; // default language
if ( isset($_SESSION['idm']) && isset($subdomains[$_SESSION['idm']]) )
$lang = $_SESSION['idm']; // selected language
// redirect while maintaining the complete request URI
header('Location: http://' . $domains[$lang] . $_SERVER['REQUEST_URI']);
exit;
}
关于php - 多语言 .htaccess 重定向到子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10367732/
是否可以在 .htaccess 中包含来自另一个 htaccess 文件的规则? .htaccess RewriteEngine On RewriteCond ... RewriteRule ...
我正在尝试做的事情: 在我的特定项目的服务器上,我想通过 htaccess 编写 URL 重写规则(从 URL 中删除 .php 或 .html 扩展名)。 我的网站网址: http://enacte
在我的 .htaccess 文件中我已经有一些重写条件和规则,并且它工作正常。 现在我需要将“http 到 https 重定向”添加到我的 htaccess 文件中。 这是我的旧 .htaccess
注意:我写了解决方案。不管怎样,谢谢你。 :) 我知道这似乎是重复的问题:我搜索了很多,我应用了数十条重写规则,但它们不起作用。 我需要从 重定向 www.domain.com/folder1 到 w
我有一个带有 drupal 的多站点,我创建了一个站点,该站点起初应该可以通过多种方式(子域和路径)访问,但现在我只想保留其中一个;所以我应该重定向所有其他人。现在我有: aaa.domain.com
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我将我的网站从/v1/etc... 目录移动到/v2/etc... 目录,并希望在 htaccess 中进行永久重定向。有人能帮我吗? 最佳答案 您可以使用 mod_rewrite : Rewrite
我想通过 .htaccess 保护文件夹。以下不起作用。它在浏览器中显示登录对话框,但看起来好像用户名和密码不匹配。当我将方法更改为 Basic 时,它运行良好。 AuthUserFile /home
任何人都可以解释以下行吗? RewriteRule ^(.*)$ /index.php/$1 [L] 最佳答案 重写规则的部分分解如下: 重写规则 表示此行将是重写规则,而不是重写条件或其他重写引擎指
我正在尝试从一个域中一个目录中的所有文件创建一个永久的 htaccess 重定向(301)到另一个域,如下所示: 重定向以下目录中的所有文件: http://www.primary.com/apple
我不是 .htaccess 的英雄,但我遇到了一个我认为可能是由它引起的问题。 第一个症状:对我的数据库的简单更改(如用户 IP 跟踪)每次请求都完成了多次,而站点的输出看起来还不错。 经过数小时的跟
我想做一个类似basecamp.com的东西:你公司的名字变成三级域名,http://mycompany.basecamp.com例如。我知道它(很可能)是在.htaccess文件和mod_rewri
我已阅读 this这对我的要求来说似乎太长了。 并尝试过 Redirect /index.php /index2.php但它不起作用(内部服务器错误) 我想要的是将我的一些 php 文件重定向到 in
如果使用此代码,则成功: Redirect 301 /products.php http://website.com.au/product_123.php 但是,如果执行此操作,则不是: Redire
我想重定向这个子域: http://abc.domain-name.com 到根域上使用相同名称的文件夹: http://www.domain-name.com/abc 这样,如果我尝试访问以下文件:
我已经在我的实时站点上设置了 htpasswd 身份验证,并且效果很好,但是当我在开发环境中工作时,我不想被要求输入密码。 在我的 httpd.conf 文件中,我有: SetEnv APP_ENV
之前 我安装了 SSL,一切运行良好!!这是我的根网络服务器 .htaccess 文件中的代码: Options +MultiViews RewriteEngine On RewriteCond %{
我要问一个非常简单的问题。当我运行我的页面时,我不希望我的链接显示这个: http://localhost/example/assets/gallery.php 我想要的是: http://local
我在 htaccess 中有说明,可以让所有请求都通过 index.php 文件。但它禁止访问文件夹和文件。因此,如果我尝试转到/uploads/products/thumbs/file.png 它会
我有一个这样的网址:https://example.com/coins/1&order_by=today以及几个类别,例如: https://example.com/coins/1&order_by=
我是一名优秀的程序员,十分优秀!