Jump to content

Struggling To Get Vanity URL's To Work


Go to solution Solved by gizmola,

Recommended Posts

I need to implement vanity url's on our web site, partly because they look "prettier" but more importantly because Google doesn't seem to like links that end in ".pgm" (many of our pages on our IBM iSeries are written using Websmart ILE and the program suffix is ".pgm").

 

I am halfway there, I think, but I am not sure if I am doing this right, and I still find taking examples of htaccess redirects and applying them to what I am trying to achieve pretty complicated.

 

All the page links are coded correctly and are going to the right place, but the browser is showing the resulting url, not the link that is clicked on.

 

Hopefully someone can help to steer me in the right direction if I explain what we have...

 

The resulting link needs to be:

http://www.mydomain.com/prodpage.pgm?name=750ml Orange Line Marker Spray Paint&item=41912

The vanity link should be:

http://www.mydomain.com/product/41912/750ml Orange Line Marker Spray Paint

I have this working using the following in .htaccess:

RewriteRule product/(.*)/(.*) http://www.mydomain.com/prodpage.pgm?name=$2&item=$1 [L]

However... the url that shows in the browser is the resulting link. I need it to be the link that is clicked on.

 

Any thoughts please. I have tried lots of things but nothing seems to give the desired result.

Link to comment
https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/
Share on other sites

I just figured out something, and I DID actually manage to get the vanity url's to work and stick in the browser address bar, however if my url is:

http://www.mydomain.com/prodpage.pgm?name=750ml Orange Line Marker Spray Paint&item=41912

it is generating the page, but instead of the links within that page being at root

mydomain.com

they are at root

mydomain.com/product/41912

so as a result the css and scripts are not loading.

 

What do I change to fix this?  I feel I am so close, and yet never quite there.

 

Aggghhhh forget it!   It's something in the conf file that is redirecting when it finds a ".pgm" in the url, and it's obviously not trimming off everything in the url between the domain and the program name.

Hopefully I can figure this out in the morning.

Make sure all the static resources (css, javascript, images etc) are using a fully qualified url, rather than a relative path and that will go away.

 

I used a relative url because our testing site has been using a sub-folder (domain.com/test/--rest of url--).

Think I figured it though, because the url rewrite seems to work and runs the pgm, however the root is taken as the full original url, not just the domain.

Well, after much deliberation, trial and error - lots of errors and it was becoming a real trial too... I bit the bullet and am now rewriting everything to use absolute links.

This way it works, but both the live and test site have to sit at the same level and be accessible using a domain.

I can't use a base reset or anything similar because not all the pages are generated using php.

But it works! Thanks for the help and for also acting as a sounding block.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.