Struggling with a simple rewrite
8 posts
• Page 1 of 1
Struggling with a simple rewrite
Hello All,
Please could you take a look at the following and let me know what I've missed. Here is my situation, I have a site where the default page (default.asp) does all the work. Different pages are returned depending upon the querystring values, the querystring pattern will always be -
/default.asp?id=2&p=page-title
I was hoping that the code below, would rewrite this to
/2/page-title
This part is working OK, but when I get to that page all links within it still contain the /2/, meaning that a link that should be written as /3/another-page-title, is actually written as /2/3/another-page-title, meaning that clicking on any link on /2/page-title just redirects to itself...
Here is my syntax --
Please let me know what i've missed.
Many thanks
Please could you take a look at the following and let me know what I've missed. Here is my situation, I have a site where the default page (default.asp) does all the work. Different pages are returned depending upon the querystring values, the querystring pattern will always be -
/default.asp?id=2&p=page-title
I was hoping that the code below, would rewrite this to
/2/page-title
This part is working OK, but when I get to that page all links within it still contain the /2/, meaning that a link that should be written as /3/another-page-title, is actually written as /2/3/another-page-title, meaning that clicking on any link on /2/page-title just redirects to itself...
Here is my syntax --
- Code: Select all
RewriteBase /
SeoRule default.asp\?id=(.+)(?:(?:&|&))p=([^&=]+)$ $1/$2 [NC,L]
RewriteRule ^(\d+)/.+$ /default.asp?id=$1 [NC,L]
Please let me know what i've missed.
Many thanks
Re: Struggling with a simple rewrite
Hello,
Please try to fix your config like this:
RewriteBase /
SeoRule default.asp\?id=(.+)(?:(?:&|&))p=([^&=]+)$ /$1/$2 [NC,L]
RewriteRule ^(\d+)/.+$ /default.asp?id=$1 [NC,L]
Please try to fix your config like this:
RewriteBase /
SeoRule default.asp\?id=(.+)(?:(?:&|&))p=([^&=]+)$ /$1/$2 [NC,L]
RewriteRule ^(\d+)/.+$ /default.asp?id=$1 [NC,L]
Re: Struggling with a simple rewrite
That's great, thanks Anton, one final question, for all URLs not affected by this, that end with .asp, is there anyway of replacing the '.asp' with a '/'?
Thanks for your help
Thanks for your help
Re: Struggling with a simple rewrite
Hello,
Please try to have the following:
SeoRule ^(?!.*default\.asp)(.*)\.asp$ $1/ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1.asp [NC,L]
If it doesn't work, please provide some examples of URLs you would like to be transformed this way.
Please try to have the following:
SeoRule ^(?!.*default\.asp)(.*)\.asp$ $1/ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1.asp [NC,L]
If it doesn't work, please provide some examples of URLs you would like to be transformed this way.
Re: Struggling with a simple rewrite
Hi Anton,
Thanks for this. so what I have is --
RewriteBase /
SeoRule default.asp\?id=(.+)(?:(?:&|&))p=([^&=]+)$ /$1/$2 [NC,L]
RewriteRule ^(\d+)/.+$ /default.asp?id=$1 [NC,L]
SeoRule ^(?!.*default\.asp)(.*)\.asp$ $1/ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1.asp [NC,L]
But there seems to be an issue with this; assuming that I want to access test.asp at root level, if i'm already on 299/bulletin/duel-in-the-sun-at-hotel
When I click on the link to test.asp, i get sent to 299/bulletin/test/ instead of test/.
If i change to /test/ i Get a 500 'The requested page cannot be accessed because the related configuration data for the page is invalid.' Error.
Thanks for your help with this.
Thanks for this. so what I have is --
RewriteBase /
SeoRule default.asp\?id=(.+)(?:(?:&|&))p=([^&=]+)$ /$1/$2 [NC,L]
RewriteRule ^(\d+)/.+$ /default.asp?id=$1 [NC,L]
SeoRule ^(?!.*default\.asp)(.*)\.asp$ $1/ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1.asp [NC,L]
But there seems to be an issue with this; assuming that I want to access test.asp at root level, if i'm already on 299/bulletin/duel-in-the-sun-at-hotel
When I click on the link to test.asp, i get sent to 299/bulletin/test/ instead of test/.
If i change to /test/ i Get a 500 'The requested page cannot be accessed because the related configuration data for the page is invalid.' Error.
Thanks for your help with this.
Re: Struggling with a simple rewrite
Hello,
So, the problem is with the base. Do you have base set on your pages?
And do you have root-relative or relative links on pages? Can you give some specific examples.
So, the problem is with the base. Do you have base set on your pages?
And do you have root-relative or relative links on pages? Can you give some specific examples.
Re: Struggling with a simple rewrite
Thanks Anton,
I've just set the base, and that has overcome the issue with the extra parameters in the url. However I'm still getting 500 Error when trying to access test.asp. The URL i'm using is just test.asp - no '/' and thne base is set as -
<base href="http://www.testmy.com" target="_blank" /> again no '/' at the end.
all of the other links are dynamic, so fall within the first set of rules.
Thank you
I've just set the base, and that has overcome the issue with the extra parameters in the url. However I'm still getting 500 Error when trying to access test.asp. The URL i'm using is just test.asp - no '/' and thne base is set as -
<base href="http://www.testmy.com" target="_blank" /> again no '/' at the end.
all of the other links are dynamic, so fall within the first set of rules.
Thank you
Re: Struggling with a simple rewrite
Hello,
So, you make a request to /test/ but you get 500 error instead of /test.asp?
If yes, please enable logging in httpd.conf by putting
RewriteLogLevel 9
and provide rewrite.log records for the request to /test/
So, you make a request to /test/ but you get 500 error instead of /test.asp?
If yes, please enable logging in httpd.conf by putting
RewriteLogLevel 9
and provide rewrite.log records for the request to /test/
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 24 guests