Glen Glen - 5 months ago 46
Apache Configuration Question

.htaccess redirect with query string on subdomain isn't working

I am trying to use htaccess to redirect a URL like:[anytexthere]/ to redirect to[theanytexthere]/

But all I keep getting is a 404 error when trying to access, here is the .htaccess sample:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule [R=301,L]


There is no query string in your source or target URL. You just need REQUEST_URI to be redirected.

You can use this rule:

RewriteEngine On

RewriteCond %{HTTP_HOST}
RewriteRule ^{REQUEST_URI} [R=301,L,NC,NE]