Dutch Bodybuilding Forums - Loans - Mortgage - Mortgage Calculator - Magazine Subscriptions

PDA

View Full Version : PHP - URL rewriting help


kukuuk101
Jan 3rd 2008, 7:31 am
i'm using below code to rewrite url. it is working fine.But i have few questions

RewriteEngine On
RewriteRule ^(.*)-(.*).htm siteview.php?pid=$1

original Url - www.domain.com/siteview.php?pid=39&title=search%20engine%20optimisation

after rewrite - www.domain.com/39-searchengineoptimisation.htm

Problems ------

1. How can i take off page ID ?
2. How can i use " -" , between two words(search%20engine%20optimisation). like this -

www.domain.com/search-engine-optimisation.htm

any ideas....

mantram
Jan 3rd 2008, 7:47 am
First you will have to write the url as
http://www.domain.com/search-engine-optimisation-39.htm
or something similar.

and mod_rewrite as

RewriteEngine On
RewriteRule ^(.*)-(.*).htm siteview.php?pid=$1&title=$2

Please check it and let me know

kukuuk101
Jan 3rd 2008, 8:13 am
Hi Mantram. thank you

it is working this way -

RewriteEngine On
RewriteRule ^(.*)-title-(.*).htm siteview.php?pid=$1&title=$2

domain.com/39-title-search-engine-optimisation.htm

have to add title .without title it is not working

kukuuk101
Jan 3rd 2008, 8:22 am
sorry mantram ,, it is working

RewriteEngine On
RewriteRule ^(.*)-(.*).htm siteview.php?title=$1&pid=$2

just have to change variable.

domain.com/search-engine-optimisation-39.htm

THANK YOU VERY MUCH. any idea how to take off page ID Number also.

mantram
Jan 3rd 2008, 8:23 am
No problem... It was my pleasure.

mantram
Jan 3rd 2008, 8:24 am
sorry mantram ,, it is working

RewriteEngine On
RewriteRule ^(.*)-(.*).htm siteview.php?title=$1&pid=$2

just have to change variable.

domain.com/search-engine-optimisation-39.htm

THANK YOU VERY MUCH. any idea how to take off page ID Number also.

domain.com/search_engine_optimisation-39.htm

should get it.