2015-08-08 64 views
1

blah.com/numberVariable/variable2.html如何用.htaccess隐藏这个URL中的第一个变量?

我想隐藏URL中的数字变量。

这里是我当前的代码:

RewriteCond %{QUERY_STRING} action=(.*) 
RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\.html$ details.php query_string=$1&action=%1 [L] 
RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\.html$ details.php?query_string=$1 [L] 

回答

0

试试这个正则表达式:

\/[^\/\n]+ 

Regex live here.

解释:

\/   # match the first '/' character 
[^\/\n]+  # and anything till the next '/' character or till the line's end 

我假设/numberVariable是第一个文件夹

希望它有帮助。

+0

我可以用htaccess代码获得一些帮助吗?每当我进行更改时,都会进入重定向循环。有人能解释我的代码行是什么意思吗? – neo

+0

@neo。那么,我不是'htaccess'专家。但我发现这个答案:_http://stackoverflow.com/q/4318171/4227915_ – 2015-08-09 15:29:43