Solved

help with rewrite rules

Posted on 2007-04-03
19
211 Views
Last Modified: 2010-03-04
In my Google Webmasters account, i get these 4 URLs as 404 page not found errors:

http://www.quest-recruiting.com/advertise/167-lead-cost-engineer-%ef%bf%bd-early-works/const./
http://www.quest-recruiting.com/apply/167-lead-cost-engineer-%ef%bf%bd-early-works/const./
http://www.quest-recruiting.com/print/162-project-engineer-%EF%BF%BD-gas-processing-and-export/
http://www.quest-recruiting.com/print/167-lead-cost-engineer-%ef%bf%bd-early-works/const./

However the correct URL for this Job is:

http://www.quest-recruiting.com/advertise/167-lead-cost-engineer---early-works---const./

In my htaccess file i have this, but it isn't working:

RewriteRule ^advertise/167-lead-cost-engineer---early-works/const./$ /advertise/167-lead-cost-engineer---early-works---const./? [R=301,L]
RewriteRule ^advertise/167-lead-cost-engineer-%ef%bf%bd-early-works/const./$ /advertise/167-lead-cost-engineer---early-works---const./? [R=301,L]
0
Comment
Question by:ellandrd
  • 10
  • 9
19 Comments
 
LVL 27

Expert Comment

by:Nopius
ID: 18856065
1) %ef%bf%bd is not the same as %EF%BF%BD, correct binary string enconing is done with capital letters '%EF%BF%BD'
2) Matching binary strings in RewriteRule pattern quite different.

Here is my test configuration for %EF%BF%BD:
RewriteEngine On
RewriteBase /
RewriteRule ^test/index.html\357\277\275$ test/index.html [R=301,L,NE]

I put these lines in document root .htaccess.
Then, when I try to access http://myserver/test/index.html%EF%BF%BD
I get into http://myserver/test/index.html
\357 is an octal representation of %EF, that's the only way to match against binary characters.
NE flag stands for No Escape

3) What for do you need this rule?:
RewriteRule ^advertise/167-lead-cost-engineer---early-works/const./$ /advertise/167-lead-cost-engineer---early-works---const./? [R=301,L]

It seems to me it does nothing.

4) What is a RewriteBase and a context of RewriteRules (is it in virtual host/directory/global/.htaccess)?

0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856083
>>1) %ef%bf%bd is not the same as %EF%BF%BD, correct binary string enconing is done with capital letters '%EF%BF%BD'
2) Matching binary strings in RewriteRule pattern quite different.

obviously i didnt know this otherwise i would have fixed it myself... but its nice to know now...

>>RewriteRule ^advertise/167-lead-cost-engineer---early-works/const./$ /advertise/167-lead-cost-engineer---early-works---const./? [R=301,L]

if you look closely, you'll see the first URL has  a "/" in the end of it.  the slashes break my site so i redirect to second URL which replaces the "/" with a "-".

>>4) What is a RewriteBase and a context of RewriteRules (is it in virtual host/directory/global/.htaccess)?

the .htaccess is under:

/public_html/root-folder/.htaccess

all files exist under: public_html/root-folder/ so i guess the rewritebase is /
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856117
still dont work... getting 404 not found..

try the urls from above again...

here is my .htaccess file:

http://www.quest-recruiting.com/htaccess.txt
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 27

Expert Comment

by:Nopius
ID: 18856137
Now we should enable rewrite rule log engine in main httpd.conf with these global options:
RewriteEngine On
RewriteLog /tmp/rewrite.log
RewriteLogLevel 5

Then restart apache, then try to  access http://www.quest-recruiting.com/print/162-project-engineer-%EF%BF%BD-gas-processing-and-export/
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856169
i cant restart apache - i have no access to server.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18856172
I tried to access this URL form telnet. It seems I get incorrect redirection because of your very first line:
RewriteRule ^(.*)$ http://www.quest-recruiting.com/$1 [R=301,L]

Which matches any request and redirects me to the same URL...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856187
will i remove this?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856193
ok i have it removed...
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18856195
Yes, backup your htaccess and remove this rule, Also append "RewriteBase /"
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18856199
I have no time today. Now you may see inside logs and paste them here. I'll see tomorrow.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856207
ok
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856218
when i add them log lines im getting Internal Server Error....
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18856507
Log lines should be in httpd.conf global section, not in .htaccess
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18856511
ok - well like i said - i dont have access to the server so i cant make these changes...
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18856552
without logs it will be difficult. I'll try to reproduce exactly yours .htaccess tomorrow and see logs.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18868943
any luck?
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18869143
Hi, again.
I loaded your config on my server. When trying to access  http://localhost/print/162-project-engineer-%EF%BF%BD-gas-processing-and-export/

I see an error:
127.0.0.1 - - [07/Apr/2007:21:21:51 +1100] [localhost/sid#81237f0][rid#82d6050/initial] (3) [per-dir /u10/v/vA0/usr/htdocs/] applying pattern '^print/162-project-engineer-\357\277\275-gas-processing-and-export/$' to uri 'print.php/162-project-engineer-О©Ґ-gas-processing-and-export/'

You may notice that rewrite engine is matching against print.php/, not print/, but I entered print/...
That's because you have a rule 'RewriteRule ^print/([^/]+)/?$ print.php?jobid=$1 [nc]' before these rules (just place it at the end of all ^print/ rewrite rules). But there may be other errors, that I missed.
Without having access to httpd.conf and rewrite log it might be quite difficult to find all errors.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18869974
still didnt work.
0
 
LVL 27

Accepted Solution

by:
Nopius earned 500 total points
ID: 18870701
It works here, but I don't have appropriate print.php script to perform further testing. I just moved rewrite rule with print.php after all ^print/ rules in .htaccess.

That's are my logs:
127.0.0.1 - - [08/Apr/2007:09:39:47 +1100] [localhost/sid#81237f0][rid#82f8050/initial] (3) [per-dir /u10/v/vA0/usr/htdocs/] applying pattern '^print/162-project-engineer-\357\277\275-gas-processing-and-export/$' to uri 'print/162-project-e
ngineer-О©Ґ-gas-processing-and-export/'
127.0.0.1 - - [08/Apr/2007:09:39:47 +1100] [localhost/sid#81237f0][rid#82f8050/initial] (2) [per-dir /u10/v/vA0/usr/htdocs/] rewrite print/162-project-engineer-О©Ґ-gas-processing-and-export/ -> /print/162-project-engineer---gas-processing-and-export/
127.0.0.1 - - [08/Apr/2007:09:39:47 +1100] [localhost/sid#81237f0][rid#82f8050/initial] (2) [per-dir /u10/v/vA0/usr/htdocs/] explicitly forcing redirect with http://localhost/print/162-project-engineer---gas-processing-and-export/
127.0.0.1 - - [08/Apr/2007:09:39:47 +1100] [localhost/sid#81237f0][rid#82f8050/initial] (2) [per-dir /u10/v/vA0/usr/htdocs/] trying to replace prefix /u10/v/vA0/usr/htdocs/ with /
127.0.0.1 - - [08/Apr/2007:09:39:47 +1100] [localhost/sid#81237f0][rid#82f8050/initial] (1) [per-dir /u10/v/vA0/usr/htdocs/] redirect to http://localhost/print/162-project-engineer---gas-processing-and-export/ [REDIRECT/301]

After last redirect to http://localhost/print/162-project-engineer---gas-processing-and-export/

I cannot access print.php (error log from apache):
[Sun Apr 08 09:39:28 2007] [debug] mod_rewrite.c(1788): [client 127.0.0.1] mod_rewrite's internal redirect status: 0/10.
[client 127.0.0.1] script '/u10/v/vA0/usr/htdocs/print.php' not found or unable to stat
[Sun Apr 08 09:39:28 2007] [error] [client 127.0.0.1] File does not exist: /u10/v/vA0/usr/htdocs/errors
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IPA - can it be run on a web server? 3 205
Guacamole and browser performance 1 103
Internal wordpress pages 404 5 43
Problem to go to page 12 101
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question