2013-05-10 30 views
0

如何htaccess文件这个网址“www.domain.com/index.php?route=custom/static/page”改写为“www.domain.com/page”基本上只是想拿出的index.php?路径=自定义/静态/从URL中。如何删除中间部分从URL - mod_rewrite的

我不知道正则表达式,所以我尝试http://www.generateit.net/mod-rewrite/,但它只能产生

RewriteEngine On 
RewriteRule ^([^/]*)$ /index.php?route=$1 [L] 

其犯规删除网址的“自定义/静态的”,我尝试了一些其他的例子很好,但只删除索引。 PHP的?并不传递变量,任何帮助表示赞赏。

回答

2

你知道使用国防部重写的概念?

在你的问题你提到使用国防部重写重定向

“www.domain.com/index.php?route=custom/static/page”, 这里$_Get['route']="custom/static/page"] $url_parameter=$_Get['route']

“www.domain.com/page”[这里_Get $ [ '路线'] = “页”],

所以现在你可以码的手动添加“自定义/静态/”以获得$_Get['route'].价值$url_parameter="custom/static"+$_Get['route'] //For PHP

使用您的mod_rewrite您可以根据您的需要,

RewriteEngine On 
RewriteRule ^([^/]*)$ /index.php?route=$1 [L] 

但是如果你需要出来的使用的.htaccess现成的解决方案,那么我建议学习“重写引擎”,而不是使用生成工具