简体   繁体   English

HTACCESS-mod_rewrite

[英]HTACCESS - mod_rewrite

I would like to rename url www.mypage.com/index.php or www.mypage.com/index_cz.php (the same version of index - just in another language) to www.mypage.com/en or www.mypage.com/cz 我想将网址www.mypage.com/index.php或www.mypage.com/index_cz.php(相同版本的索引-仅使用另一种语言)重命名为www.mypage.com/en或www.mypage。 com / cz

I have this code in .htaccess 我在.htaccess中有此代码

RewriteEngine On 
RewriteRule ^index\.php$ /en/ [R=301,L]
RewriteRule ^index_cz\.php$ /cz/ [R=301,L]

It redirects me to www.mypage.com/en or www.mypage.com/cz but it gimme back NOT FOUND... 它将我重定向到www.mypage.com/cn或www.mypage.com/cz,但没有找到给我...

Really thanks for ur help 非常感谢您的帮助

You can use: 您可以使用:

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php[?/\s]
RewriteRule ^index\.php$ /en/ [R=301,L]

RewriteCond %{THE_REQUEST} /index_cz\.php[?/\s]
RewriteRule ^index_cz\.php$ /cz/ [R=301,L]

RewriteRule ^/en/?$ index.php [NC,L]

RewriteRule ^cz/?$ index_cz.php [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM