2013-11-06 16:47



I am looking for a .htaccess that does the following:

  1. For users that visit, the server should return the index.html file from the root.

  2. For users that visit,,, etc., the server should return the index.php file from the root and pass the text after as a PHP $_GET variable.

I tried the WordPress .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But this redirects everything to the index.php file.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douzi5214 douzi5214 8年前

    Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess file:

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

    Inside index.php you can access $_GET['f'] variable that will give you requested URI.

    点赞 评论 复制链接分享