.htaccess rewrite URL which contains the name of a file

Viewed 51

I would like to rewrite my url to let my users access page /api/usermanager?type=2 from this URL /signup/firststep

This without changing the address visible on the browser bar.

I tried with this:

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

The problem is that having a signup.php file redirects me to that.

My complete .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]

Can someone help me?

Thank you

1 Answers

With your shown samples, could you please try following. Please make sure to clear your browser cache before testing your URLs.

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]
Related