I am looking for a .htaccess
that does the following:
For users that visit mydomain.com
, the server should return the index.html
file from the root.
For users that visit mydomain.com/something/
, mydomain.com/anything/123/
, mydomain.com/some%20encoded%20text
, etc., the server should return the index.php
file from the root and pass the text after www.mydomain.com/
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.