Hello and thanks to all who contribute to this seemingly mind boggling puzzle. I apologize in advance if .htaccess questions belong on server fault.

So I have to move a domain to our hosting servers, this domain will be redirected to another existing website. We need to redirect the individual pages to their respective pages on the existing website for user friendliness and SEO purposes. The URL pattern of the website being redirected are:


I have found a lot of information in regards to redirecting strings with question marks, but none seem to work and I believe it's because of the / after the ?.

The following is the last RewriteRule I've tried:

RewriteCond %{REQUEST_URI}  ^/index.php$
RewriteCond %{QUERY_STRING} ^/(.*).html$
RewriteRule ^(.*)$ http://www.domain.com/index/%1.html [R=301,L]

If I go to domain.com/index.php?/News.html the RewriteRule above results in the following:


I've also previously tried a rewrite from Drupal's site dealing with their nodes queries, but edited for the site I'm working on:

RewriteCond %{QUERY_STRING} ^/(.+)$
RewriteRule ^(.*)$ http://www.domain.com/index.php?/%1 [R=301,L]
RewriteRule ^/*(.*)$ http://www.domain.com/index/$1 [R=301,L]

The above results in a redirect loop. If I can at least get the URL to rewrite to a path with no question marks, I could then do individual redirects for the pages of the site.

Any help in getting rid of the question mark in this situation would be extremely appreciated.

Ultimately, I will be redirecting from one website to another. The websites don't have the same naming conventions, so I imagine I'll use redirect 301 path new URL for the individual pages.

An example of the start to finish, I would need to redirect the following URL:




Not all of the old site names will be the same as you see About.html matching about.html, there will be URLs with News.html going to /Blog-Folder/.

What I imagine would be most efficient is getting the /index.php?/Page.html redirected to a folder path on the initial website so that it is set up like:

domain.com/index.php?/About.html -> domain.com/index/About.html -> newsite.com/about.html

Feel free to ask for more clarification if needed, I greatly appreciate any and all help.

  • 1
    Could you edit the question and add some simple oldaddress -> newaddress examples, showing exactly what the new addresses should look like, ideally? May 15, 2013 at 17:06
  • 1
    absolutely, I appreciate your interest in helping. May 15, 2013 at 18:14

2 Answers 2


This should work for files of any extension:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^/(.*\..*)$
RewriteRule ^index\.php$ http://www.newsite.com/%1? [L,R=301]

Or to redirect the entire path and file request:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^/(.*)(\..*)$
RewriteRule ^index\.php$ http://www.newsite.com/%1%2? [L,R=301]

You could try using a simple Apache Redirect, like this:

Redirect 301 /index.php?/About.html http://www.newsite.com/about.html

It doesn't use regular expressions, so shouldn't care about the question mark and is simple to use. The only downside is that you'll need one per page - but if the structure and names aren't the same/similar on the new site, you might have to do that anyway.

  • I understand that the simple redirects don't use regular expressions, however, it still doesn't work. I've never been able to use the simple redirect to work with a question mark. I've only been able to use RewriteCond %{QUERY_STRING} for removing question marks. In this case it seems the forward slash (/) after the question mark (?) and the lack of a defined variable is causing this particular case more trouble. I appreciate your intent of helping, though! May 17, 2013 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.