1

I have the following URL

www.site.com/index.php?key=blah

I want to make it like the following using .htaccess

www.site.com/blah

How can i achieve this using .htaccess?

2
  • will you use just for key value or something else? Commented May 20, 2013 at 14:51
  • only for key parameter and only for index page Commented May 20, 2013 at 14:58

2 Answers 2

2

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ /index.php?key=$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

1 Comment

Does your index.php reside in some sub dir rather than on DOCUMENT_ROOT. Tell me more about your directory structure. Give this line a try: RewriteRule ^(.+?)/?$ index.php?key=$1 [L,QSA]
0

it is what i'm using on my website, it works on local too.

Options -Indexes

<IfModule mod_rewrite.c>
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?key=$1 [L]

</IfModule>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.