OllieMackJames Posted July 17, 2015 Share Posted July 17, 2015 Please do not tell me about the great modules that can do this a different way, I know those. I NEED htaccess 301 redirect fallback to properly work. When I add this: Redirect 301 /old.html /new-loaction/ Processwire somehow shows this: http://www.domain.com/new-location/?it=old.html with a 404 error and Warning: filemtime(): stat failed errors as well I tried this on a different domain with a different cms - modx evolution and that adds something else to the end - that is why I conclude it must be something that processwire adds. How can I get the htaccess 301 redirect to work with processwire, WITHOUT the great modules jumplinks and apeisa's redirect. Thanks! Link to comment Share on other sites More sharing options...
Macrura Posted July 17, 2015 Share Posted July 17, 2015 where are you adding it in the htaccess file? are you sure it is after the <IfModule mod_rewrite.c> also, i can't see how PW would throw an error on a page just because it has a url parameter; i've done tons of htaccess 301 redirects both with Redirect and RedirectMatch and it always works, i always put them after the www rule Link to comment Share on other sites More sharing options...
OllieMackJames Posted July 17, 2015 Author Share Posted July 17, 2015 where are you adding it in the htaccess file? are you sure it is after the <IfModule mod_rewrite.c> also, i can't see how PW would throw an error on a page just because it has a url parameter; i've done tons of htaccess 301 redirects both with Redirect and RedirectMatch and it always works, i always put them after the www rule Hi Macrura, thanks for your thoughts. Yes I did put the redirect after the <IfModule mod_rewrite.c> and tested at all different locations in the htaccess file FYI, it does redirect but adds something to the url and throws an error old.html redirects to the new url but with something added to the url, like this: /new-location/?it=old.html The errors have to do with procache This is the full error: Warning: filemtime(): stat failed for /home/xxxxxxxx/domains/xxxxxxxxxxxx.com/public_html/site/templates/styles/main.css in /home/bpgdby/domains/backpaingoodbye.com/public_html/site/modules/ProCache/ProCacheFileMerger.php on line 161 Warning: filesize(): stat failed for /home/xxxxxxxx/domains/xxxxxxxxxxx.com/public_html/site/templates/styles/main.css in /home/bpgdby/domains/backpaingoodbye.com/public_html/site/modules/ProCache/ProCacheFileMerger.php on line 161 404 Not Found tnx! Link to comment Share on other sites More sharing options...
Mike Rockett Posted July 17, 2015 Share Posted July 17, 2015 Always been a fan of mod_rewrite, and so I never use Redirect or RedirectMatch. You'll be better off doing a simple RewriteRule just below RewriteEngine On. RewriteRule ^old.html$ /new-location/ [END,R=301] 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted July 17, 2015 Author Share Posted July 17, 2015 Always been a fan of mod_rewrite, and so I never use Redirect or RedirectMatch. You'll be better off doing a simple RewriteRule just below RewriteEngine On. RewriteRule ^old.html$ /new-location/ [END,R=301] Thanks Mike - you ROCK! that works like a charm! 1 Link to comment Share on other sites More sharing options...
gdl-joe Posted August 10, 2015 Share Posted August 10, 2015 I also wanted a redirect like Redirect 301 /old.html /new-loaction/ and I tried out the code from Mike, like: RewriteRule ^anwender.html$ /anwender/ [END,R=301] The first does not work at all, the second gives back an error message. Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.The code I added at the end of the .htaccess Link to comment Share on other sites More sharing options...
Mike Rockett Posted August 11, 2015 Share Posted August 11, 2015 Hi gdl-joe, and welcome to ProcessWire. The code I added at the end of the .htaccess That's where the problem lies. You need to add that line just after RewriteEngine On. Link to comment Share on other sites More sharing options...
gdl-joe Posted August 11, 2015 Share Posted August 11, 2015 Hi Mike, thank you for your answer. But it does not help. I have the same problems as before. So I tried out the redirect module, and this workes today (astonishingly, because yesterday it did not). Is there a way to redirect all pages in one step, otherwise I must add 32 single redirects in the module? Link to comment Share on other sites More sharing options...
Mike Rockett Posted August 11, 2015 Share Posted August 11, 2015 Hi Mike, thank you for your answer. But it does not help. I have the same problems as before. So I tried out the redirect module, and this workes today (astonishingly, because yesterday it did not). Is there a way to redirect all pages in one step, otherwise I must add 32 single redirects in the module? Are you using the Redirects module, or Jumplinks? If you're using Jumplinks, then you can redirect multiple pages if they follow a common format. What URLs are we looking at here? And where do you want to send them? Link to comment Share on other sites More sharing options...
gdl-joe Posted August 11, 2015 Share Posted August 11, 2015 I used the Redirects Module. The URLs look as follow (all similar) old url: www.mysite.de/page.html or www.mysite.de/folder1/folder2/page.html new url: www.mysite/page/ or www.mysite.de/folder1/folder2/page/ "page" should be the wildcart. Link to comment Share on other sites More sharing options...
Mike Rockett Posted August 11, 2015 Share Posted August 11, 2015 I used the Redirects Module. The URLs look as follow (all similar) old url: www.mysite.de/page.html or www.mysite.de/folder1/folder2/page.html new url: www.mysite/page/ or www.mysite.de/folder1/folder2/page/ "page" should be the wildcart. Redirects does not support wildcards, which is why Jumplinks was created. In your case (I assume your intention here is to drop the .html extension from all requests), you would create a jumplink like so: Source: {all}.html Destination: {all}/ Alternatively, you can ask Jumplinks to check common extensions (such as .php, .htm, .aspx, etc.) by using the {ext} wildcard: Source: {all}.{ext} Have a look at the Wildcards and Smart Wildcards documentation pages for more information. If you would prefer to use mod_rewrite, then you can use this as the very first rule, just after RewriteEngine On: RewriteRule ^(.*).html$ /$1/ [R=301,L] 1 Link to comment Share on other sites More sharing options...
gdl-joe Posted August 13, 2015 Share Posted August 13, 2015 Thanks a lot, Mike! 1 Link to comment Share on other sites More sharing options...
Bipeen Nadgauda Posted January 30, 2016 Share Posted January 30, 2016 I also wanted a redirect like Old folder to new folder I'm using following 301 redirection code through .htaccess Redirect 301 /old-location/ http://www.mydomain.com/new-loaction/ The htaccess code does not work at all, pls help.... Link to comment Share on other sites More sharing options...
Mike Rockett Posted January 30, 2016 Share Posted January 30, 2016 I also wanted a redirect like Old folder to new folder I'm using following 301 redirection code through .htaccess Redirect 301 /old-location/ http://www.mydomain.com/new-loaction/ The htaccess code does not work at all, pls help.... Welcome to the forums, Bipeen. Where did you put that redirect directive? It should really be right at the top of the file. Link to comment Share on other sites More sharing options...
chrisbourn Posted September 14, 2017 Share Posted September 14, 2017 I'm also having similar issues I've tried several permutation, but the redirect does not work for the new gallery page Here is my current code structure: " Redirect 301 /gallery.html /new-gallery.html [END,R=301] RewriteEngine On RewriteCond %{HTTP_HOST} !^www.mysite.co.uk$ [NC] RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [L,R=301] " ...any thoughts? Thanks Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 14, 2017 Share Posted September 14, 2017 @chrisbourn - Redirect and RewriteCond/Rule are not part of the same module, and so that line is invalid because of the flags at the end. Rather use the following underneath RewriteEngine On: RewriteRule ^gallery.html$ /new-gallery.html [END,R=302] When you're happy with the redirect and you wish to make it permanent, change 302 to 301. Link to comment Share on other sites More sharing options...
chrisbourn Posted September 14, 2017 Share Posted September 14, 2017 Hi, Thank you I've tried this (again trying different variations, and its not working. Have I put this together incorrectly ? RewriteEngine On RewriteCond %{HTTP_HOST} !^www.mywebsite.co.uk$ [NC] RewriteRule ^(.*)$ http://www.mywebsitel.co.uk/$1 [L,R=301] RewriteRule ^gallery.html$ /new-gallery.html [END,R=301] Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 14, 2017 Share Posted September 14, 2017 @chrisbourn - what happens when you navigate to /gallery.html? Feel free to PM me your entire htaccess file and I'll be happy to help. Link to comment Share on other sites More sharing options...
chrisbourn Posted September 15, 2017 Share Posted September 15, 2017 I just see 404 error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. The entire htaccess file is currently as below, (I have tried different permutations RewriteEngine On RewriteCond %{HTTP_HOST} !^www.mywebsite.co.uk$ [NC] RewriteRule ^(.*)$ http://www.mywebsitel.co.uk/$1 [L,R=301] RewriteRule ^gallery.html$ /new-gallery.html [END,R=301] Thanks Chris Link to comment Share on other sites More sharing options...
Mike Rockett Posted September 16, 2017 Share Posted September 16, 2017 @chrisbourn: 22 hours ago, chrisbourn said: The entire htaccess file is currently as below Are you using ProcessWire? There should be much more than that if you are using it... Just checking. Perhaps htaccess is not enabled with your host? Link to comment Share on other sites More sharing options...
chrisbourn Posted September 25, 2017 Share Posted September 25, 2017 Seems to be working fine now. Thanks 1 Link to comment Share on other sites More sharing options...
alan Posted November 8, 2017 Share Posted November 8, 2017 Sorry if this is not too relevant to this thread, but, in case anyone is here trying to solve why they get `?it=` added to the URL and anchor redirects don't work properly, for my install that always failed I finally found a workaround. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now