404 redirection issue

Hi,

I have rebuilt an old ASPX CMS website to plain PHP website and also we changed hosting company and now using Apache.

Google still show old urls that doesn't exist anymore.
To fix that I added a 404 redirection in htaccess.

ErrorDocument 404 /index.php

Open in new window


It's working well if the old url is www.mysite.com/old.aspx
but it's not working correctly if the old url is www.mysite.com/en/old.aspx
What it does, it's display only the new content of the index but not pulled the css and js (header and footer are included file) and the url stay the same no redirection to the new index.php.

Thanks for your help
LVL 29
lenamtlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
You need to put up HTTP 301 (permanent redirection) pages to "teach" Google to forget the old ones.

http://en.wikipedia.org/wiki/HTTP_301

https://support.google.com/webmasters/answer/93633?hl=en

https://support.google.com/webmasters/answer/83105?hl=en
0
lenamtlAuthor Commented:
Hi,



How can I do it for all old pages that doesn't exist?
I cannot do this for every single pages, I mean the old site was a CMS with several pages.

How come the 404 redirection doesn't work for this url?
www.mysite.com/en/old.aspx

The domain name is the same, have not changed.
0
GaryCommented:
The last thing you should be using is a 404.
Is the folder/page structure the same?
If so you can just add to your htaccess

RewriteEngine on
RewriteRule ^(.*)\.aspx$ /$1.php [R=301,NC]


This rule should be the first before any other rewrites.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

lenamtlAuthor Commented:
No the structure is completely different
because the old aspx version was made using a custom CMS with severals page (around 50 pages) and now it is a micro site (4 pages) using PHP.
0
GaryCommented:
So how should the old pages be redirected?
0
lenamtlAuthor Commented:
Most of the pages are redirected correctly using the

ErrorDocument 404 /index.php

Open in new window


but those pages that weren't located in the root
let say www.mysite.com/en/old.aspx
are not redirected correctly

The new content is displayed (text),
all inluded files are not displayed
and the url stay the same www.mysite.com/en/old.aspx
and not changing for index.php
0
GaryCommented:
So you want everything that's .aspx just redirected to the index page.

RewriteRule ^(.*)\.aspx$ /index.php [R=401,NC]

401 tells Google the page has gone and remove from the index (which may take time)
0
lenamtlAuthor Commented:
I added your line of code into my .htaccess file and upload it.

I visited that old page www.mysite.com/en/old.aspx 
and it's not redirecting me,

I thinks the problem is because the page was not in the root but placed into /en/ directory
0
GaryCommented:
RewriteRule ^(.*).aspx$ /index.php [R=401,NC]
0
lenamtlAuthor Commented:
Unfortunately not working, I have cleared the history to make sure.
0
GaryCommented:
Can you post your htaccess.
0
lenamtlAuthor Commented:
ErrorDocument 404 /index.php
RewriteRule ^(.*).aspx$ /index.php [R=401,NC]
0
lenamtlAuthor Commented:
I have tried this

changed the htaccess to this

ErrorDocument 404 /index.php

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*).aspx$ /index.php [R=401,NC]

Open in new window


Now it's give me  401 - Unauthorized page instead of redirecting to index.php
0
GaryCommented:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*).aspx$ /index.php [R=404,NC,L] 
ErrorDocument 404 /index.php

Open in new window

0
lenamtlAuthor Commented:
Using your code it's not doing changing anything
0
GaryCommented:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*).aspx$ /index.php [R=302,NC,L] 
ErrorDocument 404 /index.php 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lenamtlAuthor Commented:
Ok this is working now
except for those that are not aspx

I will add 301 redirect for others pages
Thanks
0
lenamtlAuthor Commented:
Both solutions will help me to fix everything

Thanks a lot for your patience
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.