重写PHP友好的URL使用.htaccess文件多种语言

编程入门 行业动态 更新时间:2024-10-25 06:21:52
本文介绍了重写PHP友好的URL使用.htaccess文件多种语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有我建立了一个不育系,将节省的语言在一个XML文件,并根据不同的页面,语言选择,它会显示正确的数据一对夫妇的网站。我cuurently对每个站点的8种不同的语言和URL是这样的:

I have a couple websites that I built a CMS for that will save the languages in an XML file and depending on the page and language selector, it will show the correct data. I cuurently have 8 different languages for each of the sites and the urls are like:

leclosdamboise/index.php?lang=fr

leclosdamboise/rooms.php?lang=en

leclosdamboise/hotel.php?lang=de

我想拥有它,这样的URL重写为如下:

I am trying to have it so that the urls are rewritten to look like this:

leclosdamboise/fr/index.php

leclosdamboise/en/rooms.php

leclosdamboise/de/hotel.php

我花了几个小时通过论坛梳理和没有能够找到一个解决方案,工程。我的.htaccess文件现在看起来是这样的:

I have spent hours combing through forums and not been able to find a solution that works. My .htaccess file currently looks like this:

SetEnv PHP_VER 5_TEST SetEnv REGISTER_GLOBALS 0 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z0-9]+)$ index.php?lang=$1 [QSA,L]

这并没有做任何事情,该网址仍是丑陋的继女版。上面的链接是实际联系的地点之一。有一次,我整理了这一点,我需要它deply几个地点,但被伤透我的头试图理清了这一点。谁能告诉我什么,我做错了什么?

This does not do anything and the urls are still the ugly step-daughter version. The links above are actual links to one of the sites. Once I sort this out I need to deply it to several sites, but been racking my head trying to sort this out. Can anyone tell me what I'm doing wrong?

推荐答案

这应该工作在一个.htaccess文件的根目录下:

This should work in one .htaccess file at root directory:

Options +FollowSymlinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .* - [L] RewriteRule ^([^/]+)/([^.]+)\.php /$2.php?lang=$1 [L,NC,QSA]

更多推荐

重写PHP友好的URL使用.htaccess文件多种语言

本文发布于:2023-11-01 02:29:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   友好   多种   语言   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!