htaccess RewriteRule URL

时间:2015-02-28 12:52:46

标签: php .htaccess mod-rewrite

我正在尝试重写一堆看起来像这样的网址:

http://example.com/test/gallery/?view=gallery&gallery=214

http://example.com/gallery/?view=gallery&gallery=214

我认为画廊之后的网址不重要吗?只是想摆脱"测试"在那里。

我已经尝试过了:

RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^$ test?id=$1 [QSA,L]

提前致谢

1 个答案:

答案 0 :(得分:1)

示例代码htaccess重写

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]