This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: rewrite url to page title Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 26 January 2012 at 9:38am | IP Logged Quote visrevUK

Hi

I am trying to rewrite all urls on a site to hide the variable and replace with
the page title instead.

Please can someone help a novice rewriter???

example:

www.thesite.com/default.asp?p=X&title=pagename
to
www.thesite.com/pagename

thanks




Edited by visrevUK - 26 January 2012 at 9:56am
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 27 January 2012 at 4:17am | IP Logged Quote Guests

Hello,

Try using:

Code:
RewriteCond %{QUERY_STRING} ^p=X&title=(.*)$
Rewriterule ^default\.asp$ /%1 [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /default.asp?p=X&title=$1 [NC,L]


Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 27 January 2012 at 4:42am | IP Logged Quote visrevUK

Thanks for the reply, just tried and nothing appears to happen!

Maybe it is because where I said page=X,I meant that this can be any
number (pageID) that is passed.

So I need to write a URL that may be:

www.mysite.com/default.asp?p=34&title=tester
to
www.mysite.com/tester

OR

www.mysite.com/default.asp?p=345624&title=page2
to
www.mysite.com/page2

etc..

Any ideas?

thanks so far
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 27 January 2012 at 5:24am | IP Logged Quote Guests

Well,

It's no problem to ignore the "p=X" parameter, but what value of 'p' do we need to apply to rewrite back the nice URL?

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 27 January 2012 at 5:45am | IP Logged Quote visrevUK

Hi Andrew

The url will pass a value for "p" - this is the pageID and will set the call for the
content and "title" is passed to be the nice part of the url.

so

www.mysite.com/default.asp?p=234&title=aboutus
becomes
www.mysite.com/aboutus

obviously p and title will change for every url

thanks


Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 27 January 2012 at 6:19am | IP Logged Quote Guests

No, won't work this way.
All we can do:

Code:
RewriteCond %{QUERY_STRING} ^p=([^&]+)&title=(.*)$
Rewriterule ^default\.asp$ /%1/%2? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ /default.asp?p=$1&title=$2 [NC,L]


As a result you'll have:

www.mysite.com/default.asp?p=34&title=tester --> www.mysite.com/34/tester

If that's is not an option, please, see "Comprehensive mapfiles" in FAQ.

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 27 January 2012 at 6:37am | IP Logged Quote visrevUK

Hi Andrew

Got that working which is great, however the page is being shown as not
found...

The url is rewritten but the page is not displayed. IS there something I have
missed?

Thanks
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 27 January 2012 at 7:15am | IP Logged Quote Guests

This means the second rule didn't work.
Please, provide the rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 27 January 2012 at 8:57am | IP Logged Quote visrevUK

rewrite.log as requested:


(2) init rewrite engine with requested uri /default.asp?p=3&title=testing
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\home\default\mad-uk.org\htdocs\.htaccess
(3) applying pattern '^default\.asp$' to uri 'default.asp'
(4) RewriteCond: input='p=3&title=testing' pattern='^p=([^&]+)&title=(.*)$' => matched
(1) escaping /3/testing
(2) explicitly forcing redirect with http://www.mad-uk.org/3/testing
(2) internal redirect with /default.asp?p=3&title=testing [INTERNAL REDIRECT]


the browser is saying too many redirects???

Edited by AndrushkaUS - 30 January 2012 at 3:39am
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 30 January 2012 at 3:53am | IP Logged Quote Guests

Hm.... seems like the L flag in the first rule didn't work and it keeps redirecting & rewriting.
Try implementing NS flag in the rules.

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 30 January 2012 at 5:41am | IP Logged Quote visrevUK

I'm sorry, unsure what you mean?

I have replaced the L with NS in both rules and get the same result??
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 30 January 2012 at 5:59am | IP Logged Quote Guests

You should keep the L flag there too. Do you have any other rules that might take part in process?

Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 30 January 2012 at 7:43am | IP Logged Quote visrevUK

Current rule:

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.88

RewriteCond %{QUERY_STRING} ^p=([^&]+)&title=(.*)$
Rewriterule ^default\.asp$ /%1/%2? [NC,R=301,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ /default.asp?p=$1&title=$2 [NC,L,NS]


current log:

(2) init rewrite engine with requested uri /
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\home\default\mad-uk.org\htdocs\.htaccess
(3) applying pattern '^default\.asp$' to uri ''
(3) applying pattern '^([^/]+)/([^/]+)$' to uri ''
(2) init rewrite engine with requested uri /
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\home\default\mad-uk.org\htdocs\.htaccess
(3) applying pattern '^default\.asp$' to uri ''
(3) applying pattern '^([^/]+)/([^/]+)$' to uri ''

Edited by AndrushkaUS - 31 January 2012 at 3:46am
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 31 January 2012 at 3:51am | IP Logged Quote Guests

This log is of a little use for us.
It's the request for the root of the folder that doesn't match anything.

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 31 January 2012 at 6:42am | IP Logged Quote visrevUK

ok - totally confused...

what am i missing here? I understand the rewrite, but not why its bouncing
too many redirects

any advice?
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 01 February 2012 at 4:39am | IP Logged Quote Guests

Honestly, me either. It is not supposed to behave this way.
We did everything and it should have worked from the very beginning. I assume there might be the following issue that is often caused by double-registration:
http://www.helicontech.com/articles/isapi_rewrite-double-registration/

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
visrevUK
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 9
Posted: 01 February 2012 at 10:40am | IP Logged Quote visrevUK

Andrew = very clever chap

that was the problem....so simple yet so much a pain


thanks for your help
Back to Top View visrevUK's Profile Search for other posts by visrevUK
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 03 February 2012 at 6:14am | IP Logged Quote Guests

Awesome! 
Back to Top View Guests's Profile Search for other posts by Guests
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum