我正在尝试使用.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并将其放入后版本。
答案 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]