Search code examples
apache.htaccessmod-rewriteurl-rewritingfriendly-url

htacess RewriteRule http://domain/folder/(any searchstring) to redirect to http://domain/folder/index.php?option=$1


I am trying to create a rewrite rule in my Apache .htaccess file and the goal is: http://domain/folder/(any search string) to redirect to http://domain/folder/index.php?option=$1 example: http://domain/folder/covid to redirect to http://domain/folder/index.php?option=covid

I got this setup in htacess in http://domain/folder, but somehow it's not working:

RewriteEngine On
RewriteRule ^([^/folder]+)/([^/]+)$ http://domain/folder/index.php?option=$1 [L]

The website is hosted on http://domain/folder

Can someone help me on this?


Solution

  • You may try this .htaccess inside folder/:

    RewriteEngine On
    
    RewriteRule ^index\.html?$ index.php [L,NC]
    
    RewriteRule ^index\.php$ - [L,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .+ index.php?option=$0 [L,QSA]