Forum Moderators: open

Message Too Old, No Replies

301 URL's - Rewrite or Redirect

RewriteRule -or- Redirect permanent -or- some other method?

         

Propools

9:54 pm on Feb 20, 2012 (gmt 0)

10+ Year Member



I'm working on a site that came from Apache hosting and is on an IIS 6 server.
I need to 301 several URL's.
Do not have access to server set-up controls but do have ability to change the .htaccess file.

So, Should I use:

RewriteRule -or- Redirect permanent -or- some other method?

g1smd

10:18 pm on Feb 20, 2012 (gmt 0)

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



On Apache the advice is always "if you have used RewriteRule for any of your rules use it for all of your rules" and "if you have used RewriteRule for any of your rules do not use Redirect or RedirectMatch in the same server".

It's likely the same for IIS.

The reason for the advice is that when rules from different modules are used, you can't be sure which order they will be processed.

Propools

11:17 pm on Feb 20, 2012 (gmt 0)

10+ Year Member



g1smd Thanks.
Which Rule is better though? (Rewrite or Redirect -or- some other method)

g1smd

11:23 pm on Feb 20, 2012 (gmt 0)

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



RewriteRule can do a lot more stuff.

Redirect and RedirectMatch are somewhat limited.

Propools

11:30 pm on Feb 20, 2012 (gmt 0)

10+ Year Member



Gotcha, Thanks.

Propools

11:32 pm on Feb 20, 2012 (gmt 0)

10+ Year Member



Oh Yeah, I'm having some problems w/ my .htaccess file, think you might be able to provide a few pointers?

I am NOT a programmer, so all the help I can get would be appreciated. :)

lucy24

5:11 am on Feb 21, 2012 (gmt 0)

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



Well, give us a hint. What's in the htaccess, and what are the problems?

Didn't know it was possible to have problems with htaccess. When mine acts up, it simply shuts down the site. No middle ground.

Propools

4:45 pm on Feb 21, 2012 (gmt 0)

10+ Year Member



lucy24
For example, I cannot get the following two redirects to work correctly.

RewriteRule family.php/3031 http://www.example.com/Go_To_This-Page.php [NC,R=301,L]
RewriteRule product.php/3031 http://www.example.com/Go_To_This-Page.php [NC,R=301,L]

Both family.php/3031 and product.php/3031 end up redirecting to an error page.
The page their being directed to does exist and is accessible if I enter the URL.

I've tried putting a / in the front of the family.php & product.php, to no avail.

The file is Tab Delimited.
Other Rewrites work fine.

There's no other iterations of 3031 in the .htaccess file nor is their any other iterations of
the Go_To_This-Page.php URL's.

lucy24

8:31 pm on Feb 21, 2012 (gmt 0)

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



You definitely don't need a / in front of the pattern.

But those are a wonky URLs anyway. .php is an extension, normally meaning there won't be anything more after it (except possibly a query string, which would be ignored). / is a directory delimiter. Are these the URL formats you use in visible links on your site, so users would click them?

When you say "redirecting to an error page" do you mean that literally-- a 301 kicks in-- or do you mean that you end up seeing an error page? This is a crucial difference, because error pages are normally a special kind of rewrite. What does the browser's address bar say when you arrive at the error page?

Using an extension such as Live Headers will let you see what's happening at each step.

It looks as if you have two different pages redirecting to the same page. Is there something else going on behind the scenes, or is it simply part of an overall redesign? Or, oops, is that just the way you posted your example?

The file is Tab Delimited.

What does that mean in the context of htaccess?

Propools

9:50 pm on Feb 21, 2012 (gmt 0)

10+ Year Member



Are these the URL formats you use in visible links on your site, so users would click them?

Yes, in so much as http://www.example.com/Go_To_This-Page.php are clickable via either an image or other text.

When you say "redirecting to an error page" do you mean that literally-- a 301 kicks in-- or do you mean that you end up seeing an error page?

It's the page I've set for Error like a 404, 401 etc., but no it is not a browser page.

Using an extension such as Live Headers will let you see what's happening at each step.

Live Headers as in FireFox Live Headers?

It looks as if you have two different pages redirecting to the same page.

I know, right. I simply moved the page from the root to a folder. I don't know how to be explicit and say that though, in the .htaccess file. If I even can?

I'm not a programmer, but was told the .htaccess file had to be a Tab Delimited file.?.

g1smd

10:57 pm on Feb 21, 2012 (gmt 0)

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



Save the htaccess file as a plain ASCII text file.

example.com/product.php/3031 is a prefectly valid URL and meant for processing when AcceptPathInfo is on. Turn AcceptPathInfo off for starters!

lucy24

12:54 am on Feb 22, 2012 (gmt 0)

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



Ouch. You mean the htaccess has tabs where it ought to have spaces? I think, on the whole, that this is probably not a good idea.

Both family.php/3031 and product.php/3031 end up redirecting to an error page.
The page their being directed to does exist and is accessible if I enter the URL.

So they're being redirected somewhere else. What does the address bar say?

Firefox Live Headers is the classic. But by now there are probably equivalents that work with other browsers.

Propools

3:57 pm on Feb 22, 2012 (gmt 0)

10+ Year Member



g1smd,

I looked at AcceptPathInfo information on Apache.org and I'm wondering what setting to use.

Robert Charlton

10:16 pm on Mar 25, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Propools - You've not answered an important question related to the setup of your error page, already asked twice. I've added some emphasis....

What does the browser's address bar say when you arrive at the error page?

So they're being redirected somewhere else. What does the address bar say?