Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何为多语言网站设置.htaccess?_Php_.htaccess - Fatal编程技术网

Php 如何为多语言网站设置.htaccess?

Php 如何为多语言网站设置.htaccess?,php,.htaccess,Php,.htaccess,我需要设置.htaccess,但对于我来说,理解任何有关.htaccess代码的内容都有点困难 我已经为单一语言(克罗地亚语)设置了.htaccess,但现在我必须在文件夹“en”中添加另一种语言(英语)。因此,文件夹结构如下所示: / /index.php /items.php /item.php /contact.php /404.php /en/index.php /en/items.php /en/item.php /en/contact.php /en/404.php / or

我需要设置.htaccess,但对于我来说,理解任何有关.htaccess代码的内容都有点困难

我已经为单一语言(克罗地亚语)设置了.htaccess,但现在我必须在文件夹“en”中添加另一种语言(英语)。因此,文件夹结构如下所示:

/

/index.php
/items.php
/item.php
/contact.php
/404.php

/en/index.php
/en/items.php
/en/item.php
/en/contact.php
/en/404.php
/ or /index.php - http://localhost/website/
/items.php - http://localhost/website/items/
/items.php?place=place_1 - http://localhost/website/items/offer/place_1/
/items.php?place=place_1&sale_type=sale_type_2 - http://localhost/website/items/offer/place_1/sale_type_2/
/items.php?place=place_1&sale_type=sale_type_2&type=type_3 - http://localhost/website/items/offer/place_1/sale_type_2/type_3/
/items.php?premium=true&place=place_1&quart=quart_2 - http://localhost/website/items/premium/place_1/quart_2/
/items.php?premium=true&place=place_1&sale_type=sale_type_2&quart=quart_3 - http://localhost/website/items/premium/place_1/sale_type_2/quart_3/
/items.php?featured=true - http://localhost/website/items/featured/
/item.php?id=4269 - http://localhost/website/item/4269/
/contact.php - http://localhost/website/contact/
/404.php - http://localhost/website/404/
在我当前的.htaccess中,克罗地亚语工作得很好,而在英语中只有index.php工作,而其他页面打开404.php。 这是我当前的.htaccess文件:

RewriteEngine on

# Remove .php extension ???
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

# Don't know what this does, would say that removes .php extenstion, too ???
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://localhost/website/$1 [R=301,L]

# Add trailing "/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://localhost/website/$1/ [R=301,L]

# Pretty URLS
RewriteRule ^items/offer/(place_1|place_2)/?$ items.php?place=$1 [L,QSA]
RewriteRule ^items/offer/(place_1|place_2)/(sale_type_1|sale_type_2)/?$ items.php?place=$1&sale_type=$2 [L,QSA]
RewriteRule ^items/offer/(place_1|place_2)/(sale_type_1|sale_type_2)/(type_1|type_2|type_3)/?$ items.php?place=$1&sale_type=$2&type=$3 [L,QSA]

RewriteRule ^items/premium/(place_1)/(quart_1|quart_2|quart_3)/?$ items.php?premium=true&place=$1&quart=$2 [L,QSA]
RewriteRule ^items/premium/(place_1)/(sale_type_1|sale_type_2)/(quart_1|quart_2|quart_3)/?$ items.php?premium=true?place=$1&sale_type=$2&quart=$3 [L,QSA]

RewriteRule ^items/featured/?$ items.php?featured=true [L,QSA]

RewriteRule ^item/([0-9]+)/?$ item.php?id=$1 [L,QSA]

# Errors
ErrorDocument 404 http://localhost/website/404.php
当前URL如下所示:

/

/index.php
/items.php
/item.php
/contact.php
/404.php

/en/index.php
/en/items.php
/en/item.php
/en/contact.php
/en/404.php
/ or /index.php - http://localhost/website/
/items.php - http://localhost/website/items/
/items.php?place=place_1 - http://localhost/website/items/offer/place_1/
/items.php?place=place_1&sale_type=sale_type_2 - http://localhost/website/items/offer/place_1/sale_type_2/
/items.php?place=place_1&sale_type=sale_type_2&type=type_3 - http://localhost/website/items/offer/place_1/sale_type_2/type_3/
/items.php?premium=true&place=place_1&quart=quart_2 - http://localhost/website/items/premium/place_1/quart_2/
/items.php?premium=true&place=place_1&sale_type=sale_type_2&quart=quart_3 - http://localhost/website/items/premium/place_1/sale_type_2/quart_3/
/items.php?featured=true - http://localhost/website/items/featured/
/item.php?id=4269 - http://localhost/website/item/4269/
/contact.php - http://localhost/website/contact/
/404.php - http://localhost/website/404/
我如何制作相同的东西,但是使用en文件夹?我做错什么了吗?任何关于.htaccess代码的教程,对于根目录中具有默认语言文件的多种语言,以及单独文件夹中的其他语言,都将非常有用