ayok Posted August 18, 2008 Share Posted August 18, 2008 Hi all, One question. I want to change a php url text, for example: www.myweb.com/gbook.php?id=blah&page=bleh, in to shorter text in order to do an SEO, like www.myweb.com/gbook.php/newpage. What function do I need? thanks, ayok Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/ Share on other sites More sharing options...
trq Posted August 18, 2008 Share Posted August 18, 2008 You need the apache module mod_rewrite, nothing to do with php. Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619253 Share on other sites More sharing options...
ayok Posted August 18, 2008 Author Share Posted August 18, 2008 How can I change the apache modul on webserver? Should I ask my hosting? Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619444 Share on other sites More sharing options...
trq Posted August 18, 2008 Share Posted August 18, 2008 If your host is running apache it is highly likely mod_rewrite is enabled already. Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619561 Share on other sites More sharing options...
unkwntech Posted August 18, 2008 Share Posted August 18, 2008 if you want to do: www.myweb.com/gbook.php/newpage then you don't even need mod_rewrite, just parse $_SERVER['REQUEST_URI'] you will need mod_rewite if you want http://www.myweb.com/gbook/newpage to be the link. Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619565 Share on other sites More sharing options...
ayok Posted August 19, 2008 Author Share Posted August 19, 2008 Hi. Thanks. I think that's what I need. Is there any tutorial about parsing $_SERVER['REQUEST_URI']? I can't really find it on php.net. ayok Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619927 Share on other sites More sharing options...
trq Posted August 19, 2008 Share Posted August 19, 2008 Thats not going to work because your server will be looking for a non existent directory called newpage. mod_rewrite is what your looking for. A simple example might be. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ gbook.php?id=$1 [L] Given the url http://www.myweb.com/newpage, the variable $_GET['id'] within gbook.php would hold 'newpage'. Link to comment https://forums.phpfreaks.com/topic/120207-change-url-text/#findComment-619967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.