Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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:

domain.com/index.php?/Page.html

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:

domain.com/index/News.html?/News.html

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.

EDIT:
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:

http://www.domain.com/index.php?/About.html

to:

http://www.newsite.com/about.html

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.

share|improve this question
1  
Could you edit the question and add some simple oldaddress -> newaddress examples, showing exactly what the new addresses should look like, ideally? –  Duncan Lock May 15 '13 at 17:06
1  
absolutely, I appreciate your interest in helping. –  Howard Davis May 15 '13 at 18:14
add comment

2 Answers 2

up vote 3 down vote accepted

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]
share|improve this answer
    
That worked, thanks a ton –  Howard Davis May 20 '13 at 16:08
add comment

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.

share|improve this answer
    
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! –  Howard Davis May 17 '13 at 21:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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