Jonalyn Sofia
Jonalyn Sofia

Reputation: 73

.htaccess mod rewrite directory index

I would like to remap index.php file as a directory..

Im real url, it is simply: localhost/app/index.php?app=my-app

I am new in mod_write and I know how it really works. I tried to use this:

RewriteRule ^app/(.*)/?$ index.php?app=$1 [QSA]

And it only works with localhost/app/my-app.. now how can I make it work on with or without slashes at the end and also with a filename index.php..

I want something like this:

Upvotes: 2

Views: 40

Answers (1)

CodeBoy
CodeBoy

Reputation: 3300

RewriteRule ^app/([^/]*)(?:|/|/index\.php)$ index.php?app=$1 [QSA]

See Regex101.

EDIT: Fixes (see comments)

Upvotes: 2

Related Questions