开发者

apache rewrite static url to dynamic

开发者 https://www.devze.com 2023-03-11 10:47 出处:网络
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

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

精彩评论

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