| Author |
|
visrevUK Newbie

Joined: 26 January 2012
Online Status: Offline Posts: 9
|
| Posted: 26 January 2012 at 9:38am | IP Logged
|
|
|
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: -149
|
| Posted: 27 January 2012 at 4:17am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 27 January 2012 at 4:42am | IP Logged
|
|
|
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: -149
|
| Posted: 27 January 2012 at 5:24am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 27 January 2012 at 5:45am | IP Logged
|
|
|
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: -149
|
| Posted: 27 January 2012 at 6:19am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 27 January 2012 at 6:37am | IP Logged
|
|
|
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: -149
|
| Posted: 27 January 2012 at 7:15am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 27 January 2012 at 8:57am | IP Logged
|
|
|
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: -149
|
| Posted: 30 January 2012 at 3:53am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 30 January 2012 at 5:41am | IP Logged
|
|
|
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: -149
|
| Posted: 30 January 2012 at 5:59am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 30 January 2012 at 7:43am | IP Logged
|
|
|
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: -149
|
| Posted: 31 January 2012 at 3:51am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 31 January 2012 at 6:42am | IP Logged
|
|
|
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: -149
|
| Posted: 01 February 2012 at 4:39am | IP Logged
|
|
|
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
Online Status: Offline Posts: 9
|
| Posted: 01 February 2012 at 10:40am | IP Logged
|
|
|
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: -149
|
| Posted: 03 February 2012 at 6:14am | IP Logged
|
|
|
Awesome!
|
| Back to Top |
|
| |