| Author |
|
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 22 September 2008 at 3:29pm | IP Logged
|
|
|
Hi,
We'd like to be able to handle errors using rewrite, so we can forward the url to our sitemap page.
Is this possible with rewrite, if so can someone provide some code?
TIA PS, It would also be nice to pass in the wrong url as a query string so this can be handled.
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4840
|
| Posted: 23 September 2008 at 2:56am | IP Logged
|
|
|
Can you please provide some specific examples of what are you willing to achieve?
__________________ Regards,
Anton
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 23 September 2008 at 3:00am | IP Logged
|
|
|
http://www.mydomain.com/ddd
forwards to
http://www.mydomain.com/sitemap.php?err=ddd
or
http://www.mydomain.com/whatever/dddd/dssd
forwards to
http://www.mydomain.com/sitemap.php?err=whatever+dddd+dssd
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 24 September 2008 at 12:36pm | IP Logged
|
|
|
Anton,
This is what I have already, so I need it to work as an ELSE on these.
RewriteEngine On RewriteCond %{QUERY_STRING} (.+) RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1&%1 [L] RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1 [L] RewriteCond %{QUERY_STRING} (.+) RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1&%1 [L] RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1 [L] RewriteCond %{QUERY_STRING} (.+) RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1&%1 [L] RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1 [L] RewriteCond %{QUERY_STRING} (.+) RewriteRule tell_(.*).html index.php?act=taf&productId=$1&%1 [L] RewriteRule tell_(.*).html index.php?act=taf&productId=$1 [L] #
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4840
|
| Posted: 25 September 2008 at 9:29am | IP Logged
|
|
|
You may simplify your existing rules like:
RewriteEngine On
RewriteRule cat_(.*)\.html index.php?act=viewCat&catId=$1 [L,QSA]
RewriteRule prod_(.*)\.html index.php?act=viewProd&productId=$1 [L,QSA]
RewriteRule info_(.*)\.html index.php?act=viewDoc&docId=$1 [L,QSA]
RewriteRule tell_(.*)\.html index.php?act=taf&productId=$1 [L,QSA]
And try to add the following rule:
RewriteRule ^(?!cat|prod|info|tell)(.*)$ sitemap.php?err=$1 [NC,L]
__________________ Regards,
Anton
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 26 September 2008 at 2:35am | IP Logged
|
|
|
Anton,
Hmmm, I'm not sure whats happened, but I loose my images and my style sheet settings. I think it must be something to do with paths...
Heres some example URLs...
http://www.kidsmathstore.com/products/20-x-maths-exercise-books-square-paper-200mm-x-165mm/prod_13.html
http://www.kidsmathstore.com/about-us/info_1.html
http://www.kidsmathstore.com/products/cat_1.html
http://www.kidsmathstore.com/products/pocket-calculator-electronic-8-digit/prod_6.html
http://www.mcls4u.com/shop/products/black-/-grey-marble-teardrop-earrings/prod_4.php
You can see from the last example, extra / can be added if its used in the product time.
HELP.
TIA
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 26 September 2008 at 2:37am | IP Logged
|
|
|
Also remember I want the sitemap URL to show that URL, not the error URL.
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4840
|
| Posted: 26 September 2008 at 7:09am | IP Logged
|
|
|
When I go to the url provided above, I can see images and css.
Can you please specify what exactly doesn't work and how do you want it to work.
__________________ Regards,
Anton
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 26 September 2008 at 9:46am | IP Logged
|
|
|
Anton,
Yeah I had to put my old rewrite code back in as the site is live.
I've removed this line. RewriteRule ^(?!cat|prod|info|tell)(.*)$ sitemap.php?err=$1 [NC,L]
And it seems to work, I mean images are shown etc.
I'm thinking that other files are being used as sitemap.php ?
From the top, I want to catch URLs which would produce a 404 error sna show a special page. I don't want the 404 url to be shown, I want the special URL to be shown instead, as google with think I have lots of duplicate special pages.
Hope this makes sense and you can fix this problem.
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4840
|
| Posted: 29 September 2008 at 3:59am | IP Logged
|
|
|
What about this rule? Doesn't it work? It should send you to sitemap.php when the url doesn't start as cat or prod or into or tell.
RewriteRule ^(?!cat|prod|info|tell)(.*)$ sitemap.php?err=$1? [NC,L]
You may also try this:
RewriteRule ^(?!cat|prod|info|tell).*$ sitemap.php? [NC,L]
__________________ Regards,
Anton
|
| Back to Top |
|
| |
mindwarp Newbie

Joined: 24 April 2008
Online Status: Offline Posts: 17
|
| Posted: 29 September 2008 at 10:18am | IP Logged
|
|
|
Anton,
No still doesn't work.
If I try
http://www.kidsmathstore.com
This brings up my home page correctly.
If I try
http://www.kidsmathstore.com/index.php
This brings up the site map page.
Also if I try
http://www.kidsmathstore.com/products/speaking-times-table-tutor-cd-bundle-deal/prod_5.html
None of the images appear.
I think (?!cat|prod|info|tell) this part in incorrect, it includes some things but not others.
Maybe you come email me privately with your instant messenger ID, then we could be online at the same time and I could show you the problem in real time?
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4840
|
| Posted: 29 September 2008 at 10:49am | IP Logged
|
|
|
Please try to utilize the following code at the end of your config:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sitemap.php?err=$1 [NC,L]
__________________ Regards,
Anton
|
| Back to Top |
|
| |