Jump to content

URL rewriting help


thara

Recommended Posts

Hello everyone..

 

In my website there is a link to registered tutors. That link is something like this

 

http://www.lankainstitute.com/profiles/tutors/index.php?tutorCode=1285&tutorName=Shamdhi%20Samaranayake&city=Pelmadulla

 

So I need to rewrite this link something like this...

 

www.lankainstitute.com/1285/Shamdhi Samaranayake

 

Can anybody tell me is it possible to rewrite above original URL to my expecting URL???

 

any comments are greatly appreciated.

 

Thank you.

Link to comment
Share on other sites

Yes.. It need to index.php page.. can you help me to do this work.. I got this and tried with this it work for me but city variable and value display at the end in my pretty url. How can I take away this city from the URL. As well as there is an another case in my index.php file, then it is now my profile/tutor/index.php file can't identify my css file. I placed it into this 'profile/styles/file.css'

 

RewriteEngine On

# check if the actual request if for "this1"
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles/tutors/index.php\?tutorCode=([0-9]+)&tutorName=([^&]+)&?([^\ ]+)
# redirect to "this2"
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%3 [R=301,L,NE]

# now rewrite "this2" back to "this1"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/(.+)/$ /profiles/tutors/index.php?tutorCode=$1&tutorName=$2 [L,QSA]

any comments are greatly appreciated. 

Thank You.

Link to comment
Share on other sites

  • 2 months later...

RewriteEngine On
# check if the actual request if for "this1"
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles/tutors/index.php\?tutorCode=([0-9]+)&tutorName=([^&]+)&?([^\ ]+)
# redirect to "this2"
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%3 [R=301,L,NE]
# now rewrite "this2" back to "this1"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/(.+)/$ /profiles/tutors/index.php?tutorCode=$1&tutorName=$2 [L,QSA]

 

any comments are greatly appreciated.

 

Thank You.

Link to comment
Share on other sites

thanks for response..

 

I need to show up my new URL in browser's address bar.

 

I blocked city value from $_POST array and now only 2 values come to tutor profile page ('tutor code & tutor name'). Then Its working for me and now my tutor profile's new url display something like this 'http://www.mydomain....tutorCode/Tutor Name/'.

 

In this case, There is a backslash '/' printing at the end of my new URL. So can I know, it is possible to disapear the ending backslash from my new URL or If it is not possible can I add .html file extention to my new URL.? Then it should be something like this http://www.mydomain....Tutor Name.html

 

any comments are greatly appreciated.

 

Thank you.

Edited by thara
Link to comment
Share on other sites

There's two parts that deal with trailing slashes.

# redirect to "this2"
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%3 [R=301,L,NE]

That "/%1/%2/?%3" includes a trailing slash (just before the ?).

 

The other is

RewriteRule ^([0-9]+)/(.+)/$ /profiles/tutors/index.php?tutorCode=$1&tutorName=$2 [L,QSA]

The "^([0-9]+)/(.+)/$" requires a trailing slash.

 

It's as simple as removing the slashes. And fixing whatever links you output to not include them (if you haven't already).

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