使用.htaccess显示不同的路径

使用.htaccess显示不同的路径,.htaccess,url-rewriting,path,directory,.htaccess,Url Rewriting,Path,Directory,在我的Web服务器上,我希望保留以下文件夹结构,以便更易于维护: /de/index.html 如何通过.htaccess将webbrowserwww.mydomain.de/de/index.html中的可见URL更改为www.mydomain.de/index.html 我想在服务器上保留/de/目录,但不想在浏览器中显示它。 你有什么建议?这是一个微不足道的重写 此版本假定脚本、图像和CSS文件在标记中仍然使用/de/where.CSS结构 RewriteEngine On # Don't

在我的Web服务器上,我希望保留以下文件夹结构,以便更易于维护:

/de/index.html

如何通过.htaccess将webbrowserwww.mydomain.de/de/index.html中的可见URL更改为www.mydomain.de/index.html

我想在服务器上保留/de/目录,但不想在浏览器中显示它。
你有什么建议?

这是一个微不足道的重写

此版本假定脚本、图像和CSS文件在标记中仍然使用/de/where.CSS结构

RewriteEngine On
# Don't rewrite requests to /de or other real files
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*/(css|scripts)
# Rewrite incoming requests to their equivalent behind /de
RewriteRule ^(.*)$ de/$1 [L,QSA]
此版本还允许图像、CSS和脚本隐藏/取消隐藏:

RewriteEngine On
# Don't rewrite requests to /de or other real files
RewriteCond %{REQUEST_URI} !^/de/?
# Rewrite incoming requests to their equivalent behind /de
RewriteRule ^(.*)$ de/$1 [L,QSA]
更新 要强制将请求重定向到/de以使用新URL,请执行以下操作:

RewriteEngine On
# Force redirection out of /de
RewriteCond %{REQUEST_URI} ^/test/de/
RewriteRule test/de/(.*) http://%{HTTP_HOST}/test/$1 [L,R=301,QSA]

# Don't rewrite requests to /de or other real files
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*/(css|scripts)
# Rewrite incoming requests to their equivalent behind /de
RewriteRule ^(.*)$ de/$1 [L,QSA]

谢谢你的回答:)我会尽快试试这个。.htaccess是否仍必须在主目录中,或者我必须将其移动到/de?应将.htaccess文件放置在主目录中,在/de.I上面。我使用了第一个版本,并将图像、css等全部保存在其目录中(例如:…/de/css/all.css),并且显示了html部分get,但似乎是脚本,css和图像得到了错误的路径。路径当前为www.domain.de/test/de?@BlueHorizon,并且您当前在
/test
目录中拥有.htaccess,这是否重要?是的,.htaccess当前位于
/test
目录中。