Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

help with rewrite rules

Posted on 2007-04-03
19
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

670 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