Search code examples
apache.htaccessmod-rewritehttp-redirectmodx

Modx 301 that removes index.php?q= from all urls


I cant work out how to redirect and 301:

http://website.com/index.php?q=services.html

to

http://website.com/services.html

I need a rule to do this for all pages if possible.

I am using modx as the cms - so its not an straight forward 301.

The reason for needing this is I turned on friendly urls and google now has 2 versions of each page.

Thanks


Solution

  • Add this rule as your very first rule just below RewriteEngine On line:

    RewriteCond %{THE_REQUEST} \s/+index\.php\?q=([^\s&]+) [NC]
    RewriteRule ^ /%1? [R=302,L]