I am not sure where to look as I have not really done anything with this before, but I want to be able to write out a URL like this: www.whatever.com/view/ipad2/4587 and then when I get to index.php of the view directory, be able to pull the ipad2 product as a variable as well as the refID at the end. I have looked at how to rewrite URLs but this seems like the reverse. Any help is appreciated.
If I'm not mistaken about your question, you are looking for a mod_rewrite. There's a great tutorial by Nintendo here http://forums.digitalpoint.com/showthread.php?t=23044. Hope it helps, it's where I learnt to do my first mod_rewrite too Â
I can re-write the dynamic url to display like I want, but the URL that will be entered is static: www.whatever.com/view/ipad2/4587 and when I get to index.php inside the view folder, I am not sure how to use the first directory after the view folder and pull that as a get variable. For example: $_GET['product'] = 'ipad'
The link that Darkhodge provided is exactly what you are looking for. It is a great tutorial from the looks of it.
Best thing to do is to read through that tutorial I linked to be honest, but you can use something along these lines in your .htaccess: Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^view/(.*)/(.*)$ index.php?product=$1&productID=$2 [L] Code (markup): You can then visit the page by going to http://domain.tld/view/ipad2/12345 for example, which would be the same as going to http://domain.tld/index.php?product=ipad2&productID=12345.Â
Read up on .htaccess mod rewrite. The best way to attain what you're looking for. My site is an example of this: e.g. www.example.com/product.php?id=1 Â >>> Â www.example.com/product/1/Â
Thanks guys. I have been trying to get something working, but cant seem to get the simplest example actually re-writing. It's a Wordpress site and I know the mod-rewrite is working as Wordpress is using it. I am putting new rules in the root .htaccess file, but nothing. Is there anything different when dealing with wordpress? The one folder I am wanting to direct links to is in the root and does not use the wordpress structure, just a simple php script to redirect to other sites.
If you are using wordpress then it already has a built in setting for displaying urls this way. In the admin pages, go to settings->permalinks. You can define a custom setting to do exactly what you need.
I know how permalinks work, but this is a separate folder located in the root directory just used for redirects. The issue is none of my re-write rules seem to take affect. But I know wordpress uses them so not sure why I can not alter it.
I cant seem to find out why none of the rules I am adding work. There is already an htaccess file in the root that handles the Wordpress stuff which includes re write rules. But when I add anything like: RewriteRule ^([^/]*)/([^/]*)\.html$ /products/?prodname=$1&shopID=$2 [L] and then add a dynamic URL like products/?prodname=ipad&shopID=4561 nothing the URL does not seem to change and it simply directs me to the dynamic path. Any thoughts on why nothing happens, or am I missing something?
Search Engines usually respond positively to URL rewrites. This is just like you telling a person that a shop has moved to another location. There is a plugin in Wordpress called 301 redirects that provides you this facility and for other html pages make sure that your hosting provides the necessary support. This is done by writing the code in a .htaccess file placed at the root directory.