Forum Moderators: phranque

Message Too Old, No Replies

Redirect 301 problem

requesting comments re Redirecting 301 problem

         

donaldmoore

10:07 pm on Sep 2, 2012 (gmt 0)

10+ Year Member



We've developed a new Joomla site for a client. Their old site had aspx pages with rank which need to be redirected to the new pages. The domain name remained the same.

We have developed a .htaccess file with a subset of code as follows:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,nc]
Redirect 301 /resources/article.aspx http://example.com/resources/newarticle

When entering the URL for the old article we get this message:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /resources/article.aspx

It appears that the Redirect is never executing. Any help will be much appreciated.

Thank you.

[edited by: incrediBILL at 9:35 am (utc) on Sep 3, 2012]
[edit reason] changed to example.com to unlink sample URLs [/edit]

g1smd

10:15 pm on Sep 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use example.com in this forum to stop URL auto-linking.

Use RewriteRule for all of your rules. Do not use Redirect.

The non-www/www redirect should be last.

Escape all literal periods in patterns.

Add a blank line after every RewriteRule for clarity.

donaldmoore

10:43 pm on Sep 2, 2012 (gmt 0)

10+ Year Member



Thank you for your quick reply. This is my first attempt in this area.
By literal periods do you meand use \. instead of just .?

I have about 50 articles, so you're saying one RewriteRule for each? If it is not too much trouble, I would be grateful if you would provide the format.

Thank you again,
Don

lucy24

3:26 am on Sep 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If it is not too much trouble, I would be grateful if you would provide the format.

Wrong Forum, darn it. Some places will happily write your code for you, but over here we make you do it yourself so we can pick it to pieces and make you redo it until it's perfect. Or until everyone is exhausted.

mod_alias generally executes after mod_rewrite. This will not matter, because you will-- haha-- rewrite all your rules to use only mod_rewrite. But right now it seems to say:

RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,nc]

Redirect 301 /resources/article.aspx http://example.com/resources/newarticle

Uhm... You're redirecting to the very form of your domain name that you're about to redirect people away from?

By literal periods do you meand use \. instead of just .

Yes. This is a general Regular Expression rule, not an Apache-specific one.

Never mind your onscreen error messages. What do the logs say? A tool like LiveHeaders is even better, because it shows what-- if anything-- you've been redirected to. Logs just note the 301.

phranque

11:03 am on Sep 3, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Logs just note the 301.

however if it's a real human using a normal browser you will, with a bit of detective work, discover shortly afterward in the log file the subsequent request from the same IP and User Agent.

but yes, a response status code and header checker is a better tool for this, especially on a busy server.

donaldmoore

2:47 pm on Sep 3, 2012 (gmt 0)

10+ Year Member



Redirect 301 /resources/article.aspx http://example.com/resources/newarticle

Uhm... You're redirecting to the very form of your domain name that you're about to redirect people away from?

I may not have communicated correctly what I am trying to accomplish. The new site we have developed - example.com - has the same domain name as the old site. There were a number of articles on the old site (typically .aspx) that either Google has indexed or that other sites point to. I want to redirect permanently those old articles/URLs to the new ones.

This is my first foray into this forum and I appreciate the prompt responses and the patience with lack of experience. I will look at as many posts as I can to make sure I'm up to speed as much as possible.