2015-10-07 143 views
1

我尝试了很多使用可用示例(.htaccess指令)的组合,但无法达到我想要的效果。问题是...使用.htaccess代码从一个url中删除url参数

我实际的URL是 http://localhost/smon2/custsms/index.php?p_mob=9886419001

我要的是 http://localhost/smon2/custsms/

请帮我在wrinting的.htaccess代码行。 感谢

我很少以下项目的尝试......

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^p_mob=1$ 
RewriteRule (.*) $1? [R=permanent] 

RewriteEngine On 
RewriteCond %{QUERY_STRING} "p_mob=" [NC] 
RewriteRule (.*) /$1? [R=301,L] 

RewriteEngine On 
RewriteRule ^/custsms/%{QUERY_STRING}/?$ http : //localhost/smon2/custsms/ [NC,L] 

什么都没有工作。请帮忙。

+0

@anubhava在问题本身添加的代码。将注释部分格式化为不可读的块。 – Shortreminders

+0

你能澄清你在这里试图达到什么 - 为什么不简单地使用URL'http:// localhost/smon2/custsms /'? –

+0

好的,这个.htaccess位于哪里?它在'/ smon2 /'目录下吗? – anubhava

回答

1

这一规则替换所有当前的规则:

DirectoryIndex index.php 
RewriteEngine On 
RewriteBase /smon2/ 

RewriteCond %{QUERY_STRING} ^p_mob=\d+ [NC] 
RewriteRule ^(custsms)/index\.php$ $1/? [R=301,L,NC] 
+0

谢谢@anubhava,现在我得到的错误对象没有找到,因为URL变成http:// localhost/custsms – Shortreminders

+0

这个URL工作正常,但是当我输入http://localhost/smon2/custsms/index.php?p_mob = 9886419001它转向http:// localhost/custsms。由于没有这样的文件/目录得到404错误。 – Shortreminders

+0

啊现在修好了。清除浏览器缓存后尝试更新我的规则。 – anubhava