0

I need a few redirects in my .htaccess file, and what I've done works perfectly well in the htaccess tester, but it doesn't work at all on my server. I've spent days finding a solution, and I'm stuck. It would be wonderful if someone could help!

1) "/-" in URLs This is a good example:

https://www.haraldjoergens.com/galleries/remembrance-sunday/2012-cenotaph/-march-past/index.php?page=40

The "2012-cenotaph/-march-past" is supposed to be "2012-cenotaph-march-past"

I had though a straightforward RewriteRule ^(.*)/-(.*)$ %1-%2 [R=301,L] would do the trick, but it seems to be completely ignored.

2) Repetition needs to be removed: Due to making the "Replace" a 301 replace too early, the search engine bots try to access very wrong things:

https://www.haraldjoergens.com/galleries/rowing/index.php/galleries/rowing/

The second "/galleries/rowing" needs to be removed. My attempt via

RewriteRule ^(.+/index\.php)/.*$ /$1 [R,L]

works fine in htaccess tester, but seems to send the website into an endless loop.

Any suggestions would be really appreciated!

Thanks!!!

Harald

HaraldJ
  • 11
  • 2
  • The problem might have to do with a HTTPS redirect, if I comment that out, the rewrite seems to happen: 'RewriteCond %{HTTPS} !=on [NC] RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R]' Of course I want the HTTPS redirect. – HaraldJ Feb 19 '16 at 16:40
  • The problem seems to be indeed related to rewrites from not-www to www, and http to https. htaccess tester tells me: **The tests are stopped, using a different host will cause a redirect.** But I haven't found a way around the problem yet, unfortunately. – HaraldJ Feb 19 '16 at 17:34

1 Answers1

0

htaccess example

I dont know if this is what you really need. One thing helps me is to change the routes for example:

$route['index.php/galleries/rowing/'] = "index.php";
Community
  • 1
  • 1
  • Hi Fernando, thank you! Where would I put that statement? In htaccess, or in my PHP? In PHP it would be a problem because a lot of the code is generated, and I would have to add it any time a change to the configuration happens. A htaccess solution would be much easier. – HaraldJ Feb 19 '16 at 14:02
  • [MVC PHP WithOut Framework](http://stackoverflow.com/questions/13921249/routing-rest-requests-without-framework) I dont know if you use any framework, in my case i use cedeigniter and it have one page for routes. But in this link explains how to create your own MVC and to change the routes. – Fernando Sanchiz Feb 22 '16 at 10:52