开发者

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=开发者_如何学Python$1
RewriteRule ^live/(.*)$ live/?cat=$1

and all i have in the htaccess file is:

RewriteEngine on


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


Have this code in your .htaccess file:

Options -MultiViews +FollowSymLinks
RewriteEngine On

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


in rewrite rule the file name or extension in missing?

write rule like,

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜