Glen Glen - 1 year ago 103
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]

Answer Source

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]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download