[英]How to remove middle part from URL - mod_rewrite
如何在htaccess文件中将此网址“www.domain.com/index.php?route=custom/static/page”重写为“www.domain.com/page”,基本上只想取出index.php?route =自定义/静态/来自网址。
我不知道正则表达式,所以我尝试了http://www.generateit.net/mod-rewrite/ ,但它只生成
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?route=$1 [L]
哪个不从URL中删除'custom / static',我还尝试了其他一些例子,但只删除了index.php? 并没有传递变量,任何帮助表示赞赏。
你知道使用mod-rewrite的概念吗?
在您提出的问题中,您提到使用mod-rewrite进行重定向
“www.domain.com/index.php?route=custom/static/page”,这里
$_Get['route']="custom/static/page"
]$url_parameter=$_Get['route']
至
“www.domain.com/page”[这里$ _Get ['route'] =“page”],
所以现在你可以手动将“custom / static /”添加到$_Get['route'].
获得的值中$_Get['route'].
as $url_parameter="custom/static"+$_Get['route'] //For PHP
使用mod_rewrite可以满足您的需求,
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?route=$1 [L]
但是如果您需要使用.htaccess的开箱即用解决方案,那么我建议学习“重写引擎”而不是使用生成工具
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.