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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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'. Quote Link to comment 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.