.htaccess重写包含文件名的URL



我想重写我的url,让我的用户从此url/signup/firststep访问页面/api/usermanager?type=2

这不会更改浏览器栏上可见的地址。

我试过这个:

RewriteEngine On
RewriteRule ^(signup/firststep)$ api/usermanager?type=2 [NC,L]

问题是有一个signup.php文件会将我重定向到它。

我的完整.htaccess

ErrorDocument 404 /404
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^isexistinguser/username/(.*)$ api/usermanager?type=0&username=$1 [NC,N]
RewriteRule ^isexistinguser/email/(.*)$ api/usermanager?type=1&email=$1 [NC,L]
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(signup/firststep)$ api/usermanager?type=2 [NC,L]
Options +MultiViews
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]

有人能帮我吗?

谢谢

对于您显示的示例,您可以尝试以下操作吗。请确保在测试URL之前清除浏览器缓存。

ErrorDocument 404 /404
Options -MultiViews
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^isexistinguser/username/(.*)$ api/usermanager?type=0&username=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^isexistinguser/email/(.*)$ api/usermanager?type=1&email=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(signup/firststep)$ api/usermanager?type=2 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [L]

最新更新