我有这个网址
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 规则。请确保在测试您的网址之前清除您的缓存。
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]