Bobbi X
Bobbi X

Reputation: 197

Simple .htaccess rewrite to pass 1 parameter

Can someone please tell me what should my .htaccess file contain to create the following rewrite:

http://www.example.com/success

to call

http://www.example.com/index.php?q=success

Upvotes: 6

Views: 7860

Answers (2)

Javadotnet
Javadotnet

Reputation: 125

Following code I use for my site

RewriteEngine On

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?q=$1

RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?q=$1

or you can write following

RewriteEngine On

RewriteRule ^(.+)$ index.php?q=$1

RewriteRule ^(.+)/$ index.php?q=$1

Upvotes: 3

jaco
jaco

Reputation: 3516

Try with:

RewriteEngine On
RewriteBase /

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

Upvotes: 7

Related Questions