mahenda Posted October 29, 2019 Share Posted October 29, 2019 i want to change the link looking like http://localhost/mysite/product?name=trouser to http://localhost/mysite/product/trouser and this one below http://localhost/mysite/article?title=this%20is%20 new%20product to http://localhost/mysite/article/this-is-new-product help me please because when i use a str_replace it work but noresult is displayed .htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L] php_flag register_globals 0 php_flag magic_quotes_gpc 0 php_flag magic_quotes_runtime 0 Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/ Share on other sites More sharing options...
mahenda Posted October 29, 2019 Author Share Posted October 29, 2019 6 hours ago, mahenda said: i want to change the link looking like http://localhost/mysite/product?name=trouser to http://localhost/mysite/product/trouser and this one below http://localhost/mysite/article?title=this%20is%20 new%20product to http://localhost/mysite/article/this-is-new-product help me please because when i use a str_replace it work but noresult is displayed .htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L] php_flag register_globals 0 php_flag magic_quotes_gpc 0 php_flag magic_quotes_runtime 0 @Barand @cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571099 Share on other sites More sharing options...
mahenda Posted October 29, 2019 Author Share Posted October 29, 2019 Come on help me please Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571100 Share on other sites More sharing options...
requinix Posted October 29, 2019 Share Posted October 29, 2019 One sure-fire way to get people to not help you is to tag them and plead for their help. 7 hours ago, mahenda said: i want to change the link looking like http://localhost/mysite/product?name=trouser to http://localhost/mysite/product/trouser What RewriteRule have you tried to do this? Quote and this one below http://localhost/mysite/article?title=this%20is%20 new%20product to http://localhost/mysite/article/this-is-new-product "Can't" do that with just mod_rewrite. The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. When that's ready, What RewriteRule have you tried to do this? Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571103 Share on other sites More sharing options...
mahenda Posted November 1, 2019 Author Share Posted November 1, 2019 On 10/29/2019 at 11:09 PM, requinix said: On 10/29/2019 at 11:09 PM, requinix said: One sure-fire way to get people to not help you is to tag them and plead for their help. What RewriteRule have you tried to do this? "Can't" do that with just mod_rewrite. The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. When that's ready, What RewriteRule have you tried to do this? One sure-fire way to get people to not help you is to tag them and plead for their help. What RewriteRule have you tried to do this? "Can't" do that with just mod_rewrite. The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. When that's ready, What RewriteRule have you tried to do this? check on the htacess above Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571150 Share on other sites More sharing options...
requinix Posted November 1, 2019 Share Posted November 1, 2019 1 hour ago, mahenda said: check on the htacess above That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571155 Share on other sites More sharing options...
mahenda Posted November 3, 2019 Author Share Posted November 3, 2019 On 11/1/2019 at 2:00 PM, requinix said: That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do. On 11/1/2019 at 2:00 PM, requinix said: That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do. On 11/1/2019 at 2:00 PM, requinix said: That adds a .php extension. I'm asking what you have for this clean URL stuff you want to do. i dont have that, but i have the link like below if you have an example of an .htaccess to make a clean url please help me. //the title <div class="title"> <a href="<?php echo 'article? title='.$title['title'];?>" ><?php echo $title['title'];?></a> </div> which produce this after being clicked http://localhost/mysite/article?title=this is new%20product but i want to get this http://localhost/mysite/article/this-is-new-product if i try to use str_replace then there is no result shown after clicking the link Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571200 Share on other sites More sharing options...
requinix Posted November 3, 2019 Share Posted November 3, 2019 On 10/29/2019 at 1:09 PM, requinix said: The problem is that you want to replace spaces with hyphens. What you can do is rewrite /article/this-is-new-product to /article?title=this-is-new-product. So first make your article.php support that. I said that a few days ago. Have you done it? Have you made it so that /article?title=this-is-new-product works? Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571201 Share on other sites More sharing options...
mahenda Posted November 3, 2019 Author Share Posted November 3, 2019 16 minutes ago, requinix said: I said that a few days ago. Have you done it? Have you made it so that /article?title=this-is-new-product works? 16 minutes ago, requinix said: I said that a few days ago. Have you done it? Have you made it so that /article?title=this-is-new-product works? no i dont want this /article/this-is-new-product to /article?title=this-is-new-product i want this /article?title=this%20is%20new%20product to be /article/this-is-new-product check here RewriteRule ^([a-zA-Z0-9]+)$ article.php?title=$1 RewriteRule ^([a-zA-Z0-9]+)/$ article.php?title=$1 Quote Link to comment https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571202 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.