cancel
Showing results for 
Search instead for 
Did you mean: 

Using a shortened URL Alias and URL Rewrite

SOLVED

Using a shortened URL Alias and URL Rewrite

Hi

 

I am the developer for Magento 1.9 site at https://www.caferico.co.uk.

 

I plan to purchase a shortened domain (in the style of bit[dot]ly) for social media links. and add custom URL Rewrites to handle the shortened URL - which will all be caferico.co.uk URLs

 

so, cafe.co/123 will need to be forwarded to https://www.caferico.co.uk/vegware-catering-disposables

 

I plan to do this by aliasing the domain cafe.co to caferico.co.uk and setting up a URL Rewrite to /vegware-catering-disposables . My tests so far haven't worked, the shortened URL resolves to the home page and the path is ignored.

 

Has anyone else tried to do this? Any pointers would be gratefully received.

 

Regards

Kevin

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Using a shortened URL Alias and URL Rewrite

DWJames

 

Thanks for the reply. Yes, the alias is causing the issue.

 

I solved it with a couple of lines in .htaccess

 

#Redirect from caferi.co to caferico.co.uk with full path and query string:
# If the hostname is NOT www.caferico.co.uk
RewriteCond %{HTTP_HOST} !^www\.caferico\.co.uk$
# 301 redirect to the same resource on www.caferico.co.uk
RewriteRule (.*) https://www.caferico.co.uk/$1 [L,R=301]

 

Regards

Kevin

View solution in original post

7 REPLIES 7

Re: Using a shortened URL Alias and URL Rewrite

Hi @kevin_russell,


Which application/sotware will handle the cafe.co/123 request?

Re: Using a shortened URL Alias and URL Rewrite

Damian

 

The redirect will be handled by the Magento URL Rewrite. A 301 Permanent redirect from the shortened URL to the target URL. I think the problem is the use of an Alias.

 

Kevin

Re: Using a shortened URL Alias and URL Rewrite

Hi @kevin_russell,

 

Can you share a screenshot of an example URL you've configured?

Re: Using a shortened URL Alias and URL Rewrite

Untitled-1_r2_c2.gif

Re: Using a shortened URL Alias and URL Rewrite

To be clear, this URL correctly redirects:

 

www.caferico.co.uk/123

 

...this doesn't...

 

www.cafe.co/123

 

It simply resolves to www.caferico.co.uk

 

Regards

Kevin

Re: Using a shortened URL Alias and URL Rewrite

Hi Kevin,

I don't see why you need your shortened domain setting up as an alias.

You should be able to do what you need by simple .htaccess or nginx rewrites per url from the short domain to the long one. No alias needed. I would guess this alias is what's causing your complication.

 

Re: Using a shortened URL Alias and URL Rewrite

DWJames

 

Thanks for the reply. Yes, the alias is causing the issue.

 

I solved it with a couple of lines in .htaccess

 

#Redirect from caferi.co to caferico.co.uk with full path and query string:
# If the hostname is NOT www.caferico.co.uk
RewriteCond %{HTTP_HOST} !^www\.caferico\.co.uk$
# 301 redirect to the same resource on www.caferico.co.uk
RewriteRule (.*) https://www.caferico.co.uk/$1 [L,R=301]

 

Regards

Kevin