After scouring the interwebs for hours with no luck. I come asking directly for help I would like to simply change my url from http://www.mywebsite.com http://www.mywebsite.com/index.php http://www.mywebsite.com/index.php?p=multimedia http://www.mywebsite.com/index.php?p=contact http://www.mywebsite.com/index.php?p=new to http://www.mywebsite.com http://www.mywebsite.com http://www.mywebsite.com/multimedia http://www.mywebsite.com/contact http://www.mywebsite.com/new I have tried everything I came across the web and I got nothing but server errors or no result at all Can somebody please help
RewriteEngine on RewriteRule ^index.php$ http://www.mywebsite.com/ [R=301,L] #(the dollar sign is very important in that instance) RewriteRule ^([^/\.]+)/?$ /index.php?p=$1 [L] #(this one is an exact copy from my website, with one vairable change [the p is an a in my query string] so I know it works) If those don't work, something else is amiss in your configuration.
Thanks you This sort of works Now if I type http://www.mywebsite.com/index.php?p=multimedia it rewrites to http://www.mywebsite.com/?p=multimedia OR if I type http://www.mywebsite.com/multimedia it rewrites to http://www.mywebsite.com/?p=multimedia Is there a way to rewrite the url to a clean http://www.mywebsite.com/multimedia Will this cause issues retrieving the GET variable? I see it all the time. Sorry for the rudimentary understanding of rewrite, it's something I'm trying to wrap my head around The problem is I have a site live and I don't have the time to learn it in time to fix the urls
It should not be doing any of that, unless there is code hiding in your page. Rewrite rules are just a translation between a shown url, and the url that's actually being sent to a web server. They wont redirect to a different URL unless one specifies a redirect. If you want it to redirect, you'll have to add a couple more lines: RewriteEngine on #RewriteRule ^index.php$ http://www.mywebsite.com/ [R=301,L] #(the dollar sign is very important in that instance) RewriteRule ^index.php\?p=([A-Za-z0-9]+)$ http://www.mywebsite.com/$1 [R=301,L] RewriteRule ^([^/\.]+)/?$ /index.php?p=$1 [L] #(this one is an exact copy from my website, with one vairable change [the p is an a in my query string] so I know it works) Copy that whole block into your .htaccess. I have commented out my first rewrite rule, as I believe it might be causing some sort of issue. Let me know if this does the trick as far as the fancy urls. Keep in mind, if all your links go to pages with query strings, every link your viewer clicks on will have to send a second request once redirected. Not a problem if they have fast internet, but they might not like it if they have dialup or mobile browsers.
Thank you that absolutely worked! I changed my nav links to <li><a href="/">Home</a></li> <li><a href="multimedia">Multimdia/a></li> <li><a href="contact">Contact</a></li> <li><a href="new">New</a></li> I now have clean url's!! Thanks again