.htaccess在主域名后创建一个假子文件夹

时间:2015-01-21 08:44:42

标签: .htaccess url rewrite subdirectory

我想/需要重写我的所有产品网址

例如三种语言的产品网址。

mainurl.com/en/outdoor/wood-table
mainurl.com/de/außenbereich/holz-tisch 
mainurl.com/it/esterno/tavolo-legno

我想要/需要的是:

mainurl.com/products/en/outdoor/wood-table
mainurl.com/products/de/außenbereich/holz-tisch 
mainurl.com/products/it/esterno/tavolo-legno

在根文件夹 htdocs 中使用xampp运行Shop Local。

如何通过.htaccess重写此网址并在mainurl之后制作此假子文件夹?

这是商店系统 xt:commerce 中包含的原始.htaccess文件:

# RewriteEngine on
# RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

DirectoryIndex index.php

<IfModule mod_rewrite.c>

SetEnv HTTP_MOD_REWRITE On
Options -MultiViews
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/media/
RewriteCond %{REQUEST_URI} !^/xtAdmin/
RewriteCond %{REQUEST_URI} !^/skin/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php

</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 seconds"
    ExpiresByType image/x-icon "access plus 2692000 seconds"
    ExpiresByType image/jpeg "access plus 2692000 seconds"
    ExpiresByType image/png "access plus 2692000 seconds"
    ExpiresByType image/gif "access plus 2692000 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 2692000 seconds"
    ExpiresByType text/css "access plus 2692000 seconds"
    ExpiresByType text/javascript "access plus 2692000 seconds"
    ExpiresByType application/x-javascript "access plus 2692000 seconds"
</IfModule>
<IfModule mod_headers.c>
    <FilesMatch "\\.(ico|jpe?g|png|gif|swf|css|js)$">
        Header set Cache-Control "max-age=2692000, public"
    </FilesMatch>
    Header unset ETag
    Header unset Last-Modified
</IfModule>

1 个答案:

答案 0 :(得分:0)

RewriteEngine on下面插入此规则:

RewriteRule ^product/(.*) $1 [L,NC]