.htaccess url重写域名后获取信息

时间:2013-07-09 04:32:53

标签: php

我正在尝试使用.htaccess url rewrite来转换网址: -

之前:http://mydomain.com/en/Home

之后:http://mydomain.com/index.php?page=en/Home

我知道.htaccess级别,我将准备这些: -

RewriteEngine On
RewriteBase /
RewriteRule ^$ index.php?page=$X [L]

但我不知道如何将en / Home放入$ X并将其放入后版本。

2 个答案:

答案 0 :(得分:0)

您需要建立匹配类

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

答案 1 :(得分:0)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/.+)$ /index.php?page=$1 [L,QSA]