重写htaccess文件中的网址-删除查询字符串 [英] Rewrite urls in htaccess file - remove query string
本文介绍了重写htaccess文件中的网址-删除查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此之前,我从未编辑过.htaccess文件,因此对不起我的尝试
I have never edited the .htaccess file before so sorry for my awful attempt
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^(.*)$ http://example.site/index/%1 [R=302,L]
我正在尝试重写 http://ex.com/shop/?s=sa 看起来像 http://ex.com/shop/sa
I am tryting to rewrite http://ex.com/shop/?s=sa to look like http://ex.com/shop/sa
推荐答案
我假设您在商店目录中使用rewriterules
,而index.php正在处理数据,然后尝试以下操作.
I am assuming you are using rewriterules
in shop directory and index.php is handling the data then try with below.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)$ index.php?s=$1 [L]
这篇关于重写htaccess文件中的网址-删除查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文