开发者

remove query string from url through mod rewrite

开发者 https://www.devze.com 2023-01-17 18:18 出处:网络
I am very new to mod rewrite so any help would be apprecited. let say ihave a site named \"www.sitename.com/index.php?p=contact\"

I am very new to mod rewrite so any help would be apprecited.

let say i have a site named "www.sitename.com/index.php?p=contact" and i need to remov开发者_如何学Ce "index.php?p=" so that it will look like "www.sitename/contact" at its every occurence that means either i should be able to truncate "index.php?p=" or i should be able to replace it with some word.


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?p=$1


@zerkms Your answer doesn't work, it's not complete

There should be

RewriteCond %{REQUEST_URI} ^/[^.]+$
RewriteRule (.*) index.php?p=$1

These lines matches URI with no extension, so .php and .html files will still be available

0

精彩评论

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