Jump to content

Recommended Posts

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

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571099
Share on other sites

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:

What RewriteRule have you tried to do this?

Quote

"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?

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571103
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571150
Share on other sites

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
 

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571200
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571201
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/309433-help-me-clean-url/#findComment-1571202
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.