.htaccess redirect/rewrite help needed

徘徊边缘 提交于 2020-01-03 03:13:11

问题


I am writing htacess redirect rule but it is not working properly I have tried many solutions but simply it is not working.

What I want to do is to I have url http://example.com/cms/index.php?page=filename I want this url to be executed and show appropriate page but in browser it should show example.com/cms. And what is important is I only want to right this rule for this page only and it should not effect to other pages.

Thank you.


回答1:


RewriteRule ^([^/]+)/$ /cms/index.php?filename=$1 [L,QSA]

The L at the end says it is the last rule (stop processing) and QSA means 'Query String Append', so if someone puts other parameters after it, such as:

http://example.com/cms.htm?order=desc

The GET value for order will be passed also - without it it'll just quietly drop it.




回答2:


Something like this ought to work:

RewriteEngine on
RewriteRule ^http://example.com/cms$ http://example.com/cms/index.php?page=filename

...should work.

Have a look at a tutorial with some examples if you're interested in seeing what else you can do.



来源:https://stackoverflow.com/questions/1432296/htaccess-redirect-rewrite-help-needed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!