poddys Posted October 15, 2014 Share Posted October 15, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/ Share on other sites More sharing options...
poddys Posted October 15, 2014 Author Share Posted October 15, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/#findComment-1493605 Share on other sites More sharing options...
Solution gizmola Posted October 15, 2014 Solution Share Posted October 15, 2014 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/#findComment-1493606 Share on other sites More sharing options...
poddys Posted October 15, 2014 Author Share Posted October 15, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/#findComment-1493612 Share on other sites More sharing options...
poddys Posted October 15, 2014 Author Share Posted October 15, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/#findComment-1493615 Share on other sites More sharing options...
poddys Posted October 16, 2014 Author Share Posted October 16, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291632-struggling-to-get-vanity-urls-to-work/#findComment-1493891 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.