开发者

.htaccess rewrite url with parameter

开发者 https://www.devze.com 2023-04-07 10:33 出处:网络
I wan开发者_开发技巧t to change my url with only the parameter. As I am passing only one parameter, so I want the sub url should be changed with my parameter name. I want change the url as the followi

I wan开发者_开发技巧t to change my url with only the parameter. As I am passing only one parameter, so I want the sub url should be changed with my parameter name. I want change the url as the following type-

From:

http://www.xyz.com/cat.php?slag=season

to

http://www.xyz.com/season

Can anyone help me to do it. I don't know how to do it. Thanks



Options +FollowSymLinks 
RewriteEngine On  
RewriteBase /path/to/your/directory 
RewriteRule ^(.*)cat/(.*)$ cat\.php?slag=$2&%{QUERY_STRING} [L]

put the above in your .htaccess file.. and that would do the magic..

Note : RewriteBase /path/to/your/directory (use this line only if your application is in any of subfolder the folder)


I suggest you obtain a copy of the .htaccess that WordPress uses. It's a quite powerful starting point that allows you to handle routing internally from within your Application - which you might feel more comfortable with, as it seems to me.

0

精彩评论

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