Link to home
Create AccountLog in
Avatar of joshky
joshky

asked on

How do I set up a URL rewriter for a Linux-based GoDaddy host (htaccess seems crippled)

I have a Microsoft-based hosting account with GoDaddy currently
and to facilitate redirection I have errors redirected to an ASP script which then rewrites the
URL to point to another host and creates a frame.    I need to consolidate this account with
a Linux account and this is the last thing that needs to be changed before I can transfer.

I have another Linux-based account and have tried to no avail to get an htaccess solution functional,
and am hoping someone here has some experience with GoDaddy's restrictions and implementations.
I don't redirect the entire domain, but I need to redirect (preferably in a frame) URLs as shown:

http://mydomain/e/12345 ->  http://otherdomain/entries/12345
http://mydomain/t/12345  ->  http://otherdomain/tickets/12345

Options +FollowSymlinks
Options -MultiViews
RewriteEngine on
RewriteRule ^/e/([0-9]+) /e/rd2.php?rtype=e&article=$1 [R=301,NC]
RewriteRule ^/t/([0-9]+) /t/rd2.php?rtype=t&article=$1 [R=301,NC]

I think the problem lies in my PHP code for "rd2.php", which I basically pieced together ... So please take
a look at the attached and make / suggest corrections (or rewrite completely).

Note that GoDaddy's mod_rewrite appears to restrict the redirection/rewrite to reference only
files hosted on GoDaddy.

If you have access to a GoDaddy Linux host please test it out to see if it is working prior to
response.  Let me know if I've omitted anything important and I'll try to respond as soon as possible...

Thanks!

P.S. When attempting to do this, I used the following as points of reference:
http://corz.org/serv/tricks/htaccess2.php
http://davidwalsh.name/mod_rewrite-htaccess-godaddy

rd2-ee.php
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

Re your request for rules to handle the following redirects:

http://mydomain/e/12345 ->  http://otherdomain/entries/12345
http://mydomain/t/12345  ->  http://otherdomain/tickets/12345

The following should do / replace the need for your own php code, unless you wish to IFrame the redirect.:

RewriteRule ^/e/([0-9]+)   http://otherdomain/entries/$1  [R=301,NC]
RewriteRule ^/t/([0-9]+)    http://otherdomain/tickets/$1  [R=301,NC]

Note: the above rules will change the URL showing in the browser address bar.
Avatar of joshky
joshky

ASKER

Arober11,
Thanks for the reply.  But, I'm afraid it hasn't proven to be this simple.   This is why I'm hoping someone familiar with GoDaddy Apache Linux hosting will be able to chime in.   I don't know the specifics of WHY this doesn't work, but I've spent quite a bit of time myself tinkering and it has been to no avail.

Thanks in advance for any further comments.
Avatar of joshky

ASKER

For clarification, if I do try to do as you suggest Arober11, I receive an HTTP/404 error message when attempting to access one of the example URLs.
ASKER CERTIFIED SOLUTION
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of joshky

ASKER

Worked like a charm.  Thanks!
Avatar of joshky

ASKER

ARober11,
I posted a related question that you may be interested in also ... although this solution is working, it is based on implementation of the PHP portion:
https://www.experts-exchange.com/questions/26608575/Correct-PHP-code-for-hidden-frame-based-redirection-sent-from-htaccess.html