help with rewrite rules

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]
LVL 16
ellandrdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Artysystem administratorCommented:
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
ellandrdAuthor Commented:
>>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
ellandrdAuthor Commented:
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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Artysystem administratorCommented:
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
ellandrdAuthor Commented:
i cant restart apache - i have no access to server.
0
Artysystem administratorCommented:
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
ellandrdAuthor Commented:
will i remove this?
0
ellandrdAuthor Commented:
ok i have it removed...
0
Artysystem administratorCommented:
Yes, backup your htaccess and remove this rule, Also append "RewriteBase /"
0
Artysystem administratorCommented:
I have no time today. Now you may see inside logs and paste them here. I'll see tomorrow.
0
ellandrdAuthor Commented:
ok
0
ellandrdAuthor Commented:
when i add them log lines im getting Internal Server Error....
0
Artysystem administratorCommented:
Log lines should be in httpd.conf global section, not in .htaccess
0
ellandrdAuthor Commented:
ok - well like i said - i dont have access to the server so i cant make these changes...
0
Artysystem administratorCommented:
without logs it will be difficult. I'll try to reproduce exactly yours .htaccess tomorrow and see logs.
0
ellandrdAuthor Commented:
any luck?
0
Artysystem administratorCommented:
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
ellandrdAuthor Commented:
still didnt work.
0
Artysystem administratorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.