Jump to content

htaccess 301 Redirect does not work


OllieMackJames
 Share

Recommended Posts

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

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

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

  • 4 weeks later...

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 Error
The 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

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

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

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

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]
  • Like 1
Link to comment
Share on other sites

  • 5 months later...

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

  • 1 year later...

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

@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

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

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

  • 2 weeks later...
  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...