laflair13 Posted December 14, 2010 Share Posted December 14, 2010 Hey all, Not sure if this is the right section, So I apologize if not and please move to correct area. Ok, my question is, I have a site where I can add stuff quick through the admin. But it gives is a numeric url. And example mydomain.com/pop.php?Play=179 But I want it to say something like mydomain.com/here-is-a-seo-page Is there any way to do this, and if so can you point me in the right direction so I can learn it and put it on my site. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/ Share on other sites More sharing options...
K_N Posted December 14, 2010 Share Posted December 14, 2010 It's all right there in the sticky at the top of this forum, but for quick reference... If your server does have mod_rewrite enabled, add the following to your .htaccess file in the same directory as pop.php: RewriteEngine On RewriteRule ^([0-9-]+)$ pop.php?Play=$1 [L] This will make it so any request for "http://mydomain.com/179" loads "http://mydomain.com/pop.php?Play=179" Alternatively you could make it look like "http://mydomain.com/play/179" like this: RewriteEngine On RewriteRule ^/play/([0-9-]+)$ pop.php?Play=$1 [L] If you want to do anything more advanced, I suggest checking out the cheat sheet in the sticky. Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/#findComment-1147423 Share on other sites More sharing options...
laflair13 Posted December 14, 2010 Author Share Posted December 14, 2010 I appreciate it. But I want the domain.com/pop.php?play to become domain.com/play/shows-title Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/#findComment-1147425 Share on other sites More sharing options...
K_N Posted December 15, 2010 Share Posted December 15, 2010 That wouldn't be too hard, you just need to use this: RewriteEngine On RewriteRule ^/play/([A-Za-z0-9-]+)$ pop.php?Play=$1 [L] And then have a php function to take $_GET['Play'] (which would contain shows-title) and search your database for the correct thing to play. Unless I'm misunderstanding and you want it to retrieve the title from the database and insert it in the url? Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/#findComment-1147454 Share on other sites More sharing options...
laflair13 Posted December 15, 2010 Author Share Posted December 15, 2010 Your exactly right, I want it to pull the data from the database and put it in the url. So it will look like domain.com/stream/Here-is-the-title I have been reading up on it and in order to have it say stream, I would have to rename the pop.php to stream.php Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/#findComment-1147457 Share on other sites More sharing options...
K_N Posted December 15, 2010 Share Posted December 15, 2010 Well, you can't change the URL once the page has been loaded... the point of a url is to access a page. Nope, you don't have to rename it. RewriteEngine On RewriteRule ^/stream/([A-Za-z0-9-]+)$ pop.php?Play=$1 [L] Will do that. Quote Link to comment https://forums.phpfreaks.com/topic/221687-getting-clean-urls-for-seo/#findComment-1147529 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.