This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: rewrite url to page title
Author
Message |
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 26 January 2012 at 9:38am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 January 2012 at 4:17am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 27 January 2012 at 4:42am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 January 2012 at 5:24am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 27 January 2012 at 5:45am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 January 2012 at 6:19am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 27 January 2012 at 6:37am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 January 2012 at 7:15am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 27 January 2012 at 8:57am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 30 January 2012 at 3:53am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 30 January 2012 at 5:41am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 30 January 2012 at 5:59am

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

Back to Top
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 30 January 2012 at 7:43am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 31 January 2012 at 3:51am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 31 January 2012 at 6:42am

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
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 01 February 2012 at 4:39am

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
 
visrevUK
Newbie


Joined: 26 January 2012
Posts: 9
Posted: 01 February 2012 at 10:40am

Andrew = very clever chap

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


thanks for your help
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 03 February 2012 at 6:14am

Awesome! 
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version