我的 htaccess :
RewriteEngine on
RewriteCond %{THE_REQUEST} \.php[/\s?] [NC]
RewriteRule !^error - [R=404,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
我想这样做:
http://localhost:1993/test => load test.php but hide extension
http://localhost:1993/test.php => error 404 page
http://localhost:1993/test?lang=en (en, cs, fr etc) => http://localhost:1993/test
我有此链接根据此link
更改我的语言<a href="<?php echo basename($_SERVER["SCRIPT_FILENAME"], '.php') . '?lang=cs';?>"><?=$lang["lang-cs"];?></a>
语言切换有效,但点击该链接会将URL更改为 http://localhost:1993/test.php并显示404错误。
我想要重定向(点击此链接后停止在URL中添加.php)
http://localhost:1993/test?lang=en =&gt; http://localhost:1993/test