301 Redirect Issues

Happy New Year!

I’ve been working with a client on building their all new website, but I’m running into problems with my 301 redirects. I’ve done this before, but never had a problem.

In my htaccess I have:

Redirect 301 / https://newclientsite.com
Redirect 301 /one-product-type.php https://newclientsite.com/one-product-type.php

The root redirects perfectly. Yes! But for the pages, Safari shows this as the redirected URL

https://newclientsite.comone-product-type.php

As you can see, for some reason the / is being removed between .com and the page name.

Any idea what’s going on here or how to fix?

Perhaps it would be easier to understand what is happening if we saw the actual URLs and htaccess file.

Since I don’t know what URL(s) you are trying to redirect and to where you want to go with it, it’s hard to guess what might be happening.

Apache directives like redirects are very specific so talking with hypothetical values like “newclientsite.com" tends to be error-prone.

Sure thing.

Old URL: precisionboring.com
New URL: precisionadvancedmachining.com

301 redirects in htaccess

Redirect 301 / https://precisionadvancedmachining.com
Redirect 301 /press-parts-repair.php https://manorindustries.com
Redirect 301 /5-axis-cnc-machining.php https://precisionadvancedmachining.com/large-5-axis-machining.php
Redirect 301 /about.php https://precisionadvancedmachining.com/about.php

Main page (Appears to be working correctly): https://precisionboring.com

Press Parts Page (tries to redirect to the wrong destination): https://precisionboring.com/press-parts-repair.php

5-Axis page (error): https://precisionboring.com/5-axis-cnc-machining.php

Full htaccess

ErrorDocument 404 /404.php

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_include handler ^cgi-script$
</ifModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

Redirect 301 / https://precisionadvancedmachining.com
Redirect 301 /press-parts-repair.php https://manorindustries.com
Redirect 301 /5-axis-cnc-machining.php https://precisionadvancedmachining.com/large-5-axis-machining.php
Redirect 301 /about.php https://precisionadvancedmachining.com/about.php

Redirect 302 /suppliers https://precisionadvancedmachining.com/resources/documents/supplier-requirements.pdf


Seems to work now? At least for me. You might have the redirects cached. I always tell people NOT TO USWE 301’s until you have tested everything. Permanent (301) are forever, they have no expiry date and can cached until a client or proxy runs out of cache.

Okay, where are you putting these redirects on the old site or the new?

On the old site you only need the redirects in the htaccess file, not the new site.
You also need nothing else on the old site (cache or gzip) just the redirects.

On the new site, you don’t need redirect from the old.

I can’t get to the old site right now. But it looks like from the redirects you only had 3 pages?
Do you have a list of all the old pages and where you want them to go on the new site?

You also should have a force to www or remove www and a redirect to https?



Okay, I updated the htaccess from the old site with all of the 301s.

Redirect 301 / https://precisionadvancedmachining.com
Redirect 301 /replacement-press-parts.php https://manorindustries.com
Redirect 301 /precision-machining.php https://precisionadvancedmachining.com/precision-component-machining.php
Redirect 301 /precision-grinding.php https://precisionadvancedmachining.com/large-od-id-grinding.php
Redirect 301 /5-axis-cnc-machining.php https://precisionadvancedmachining.com/large-5-axis-machining.php
Redirect 301 /about.php https://precisionadvancedmachining.com/about.php
Redirect 301 /contact.php https://precisionadvancedmachining.com/contact.php

Redirect 301 /resources/Documents/iso.pdf https://precisionadvancedmachining.com/resources/documents/iso.pdf
Redirect 301 /resources/Documents/supplier-requirements.pdf https://precisionadvancedmachining.com/resources/documents/supplier-requirements.pdf

Redirect 302 /suppliers https://precisionadvancedmachining.com/resources/documents/supplier-requirements.pdf

It looks like the root is redirecting, but for some reason the / is being removed between the .com and the browser is using the old page name instead of the new one defined in the 301. This is the central problem that I cannot figure out.

Example: https://precisionboring.com/precision-grinding.php
redirects in browser to:
https://precisionadvancedmachining.comprecision-grinding.php
According to my redirect it should be:
https://precisionadvancedmachining.com/large-od-id-grinding.php

Dreamhost has the new domain set up to force non-www and https.

SOLVED

May be a hack, but it worked.

I removed the 301 on the root and used a Cloudflare rule to redirect it. All of my subsequent redirects now work as expected.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.