使用 .htaccess 删除或隐藏网址中的特定字符串

问题描述 投票:0回答:1

我有这个网址

https://test.app/myapp/login
。我想要的只是使用 .htaccess 删除“myapp”字符串。这是我到目前为止尝试过的。

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]     

RewriteCond %{QUERY_STRING} ^(.*)&?myapp=([^&]+)&?(.*)$
RewriteRule ^(.*)$ /$1?%1%3 [R=301,L]

但它不起作用。顺便说一句,使用 codeigniter 4

.htaccess mod-rewrite codeigniter-4
1个回答
0
投票

使用您显示的示例,请尝试遵循 .htaccess 规则。请确保在测试您的网址之前清除您的缓存。

RewriteEngine ON

RewriteRule ^myapp/login/?$  /login [R=301,L,NC]

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php?$1 [L,QSA] 
© www.soinside.com 2019 - 2024. All rights reserved.