Reputation: 1743
I am building a web app that puts out a link like the following:
http://www.sample.com/?a=bj7phm
I would like for it to look something like this:
Is this possible within the HTACCESS?
-B
Upvotes: 1
Views: 3239
Reputation: 13843
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([0-9a-zA-Z+]{1,7})$?a=$1 [L]
</IfModule>
Upvotes: 0
Reputation: 95344
In order to do URL rewriting, you first need to:
mod_rewrite
enabled on your server..htaccess
file.AllowOverride
must be set to All
or include FileInfo
)Then create the following .htaccess
file in your web root:
RewriteEngine On
RewriteRule ^([\-_0-9A-Za-z]+)$ index.php?a=$1 [L]
You can customize RewriteRule
as much as you want.
The first parameter is the regular expression to match the REQUEST_URI
with (relative to the folder the .htaccess
is in).
The second parameter is what you want to rewrite it to, $n
being your match groups.
Upvotes: 1