Y.G.J
Y.G.J

Reputation: 1108

apache rewrite static url to dynamic

I'm try to rewrite my url

http://www.domain.com/live/randomword

it should go rewrite to

http://www.domain.com/live/?cat=randomword

here are my tests:

RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1

and all i have in the htaccess file is:

RewriteEngine on

Upvotes: 0

Views: 677

Answers (3)

amolv
amolv

Reputation: 1008

in rewrite rule the file name or extension in missing?

write rule like,

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

Upvotes: 0

anubhava
anubhava

Reputation: 785276

Have this code in your .htaccess file:

Options -MultiViews +FollowSymLinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]

Upvotes: 0

malko
malko

Reputation: 2382

You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:

RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]

If this still doesn't work be sure to check that mod_rewrite is enabled

also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.

hope this help

Upvotes: 1

Related Questions