Stanley Ngumo
Stanley Ngumo

Reputation: 4239

Using .htaccess to redirect to relative address

I am very new to URL rewriting using .htaccess and I would like to redirect anyone entering the domain below

http://domain.tld/admin

to be redirected to

http://domain.tld/index.php?section=admin

but without including the full address. This is the code I am using but it doesnt seem to work

Options -Indexes
Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^admin /index.php?section=admin
</IfModule>

Where Im I going wrong?

Thanks

Upvotes: 1

Views: 47

Answers (1)

anubhava
anubhava

Reputation: 785156

You can use this more correct regex rule with L flag:

Options +FollowSymLinks -Indexes

RewriteEngine On
RewriteBase /

RewriteRule ^admin/? index.php?section=admin [L,QSA,NC]

Upvotes: 1

Related Questions