Welcome to HostingForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

mod_rewrite with 404 not found error at localhost

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Related Topics:
mod_rewrite returns 404 not found error - hi guys, tried to make url rewrite like: into while 404 error, please help: > On ..

Localhost error - Can anyone explain this error: Apache 2.0.52 win on an XP laptop. PHP 4.3.9. Unable to complete network request to host Failed to locate host machine. Undefined service I have checked php.ini and and..

Strange 403 error - no problem with localhost - I've searched the forums on this and can't seem to find out what's going on. I'm running Apache 2.2 with PHP 5 on Windows. I have a file, index.php (below) that does load: the form with the name, password, and submit all load on the screen.

mod_rewrite example? - I've been looking through the info from here: I still dont how to make something like the Get rewritten to say:..

help please about mod_rewrite - Hello...i needed about to redirect all user something like to using an .htacces file with the following code but it doesn't work! Can anyone help me? file .htacces contents ..
Next:  Apache: .htaccess and redirect  
Author Message
freech

External


Since: Feb 17, 2008
Posts: 8



(Msg. 1) Posted: Sat Feb 23, 2008 7:23 am
Post subject: mod_rewrite with 404 not found error at localhost
Archived from groups: alt>apache>configuration (more info?)

Hi there,

I'm configuring the effect at my own PC of:
if I type in the URL http://localhost/abc.com/show/177 this URL then
processed behind the scenes by
http://localhost/abc.com/show.php?tid=177 without I ever seeing this
second url.

While encountered problem with:
when input in url: http://localhost/abc.com/show/177
returns with : Not Found , The requested URL /abc.com/show/1052 was
not found on this server.

Environment:
windows xp sp2 + Apache/2.0.52 (Win32) PHP/5.1.4 Server at localhost
Port 80

Configuration in httpd:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost$
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} \.php$
RewriteCond %{QUERY_STRING} &?tid=(.+)&?
RewriteRule (.*)\.php$ $1/%1? [R]
RewriteRule ^/viewblog/(.+)/?$ http://localhost/abc.com/show.php?tid=$1[L]
</IfModule>


rewrite.log

127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (2) init rewrite engine with requested uri /
abc.com/show.php
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (3) applying pattern '(.*)\.php$' to uri '/
abc.com/show.php'
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (4) RewriteCond: input='localhost'
pattern='^localhost$' => matched
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (4) RewriteCond: input='/abc.com/show.php'
pattern='!^/index\.php$' => matched
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (4) RewriteCond: input='/abc.com/show.php'
pattern='\.php$' => matched
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (4) RewriteCond: input='tid=1052' pattern='&?
tid=(.+)&?' => matched
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (2) rewrite /abc.com/show.php -> /abc.com/show/
1052?
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (3) split uri=/abc.com/show/1052? -> uri=/abc.com/
show/1052, args=<none>
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (2) explicitly forcing redirect with
http://localhost/abc.com/show/1052
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (3) applying pattern '^/viewblog/(.+)/?$' to uri
'http://localhost/abc.com/show/1052'
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (1) escaping http://localhost/abc.com/show/1052
for redirect
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f40330/initial] (1) redirect to http://localhost/abc.com/show/1052
[REDIRECT/302]
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f9e100/initial] (2) init rewrite engine with requested uri /
abc.com/show/1052
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f9e100/initial] (3) applying pattern '(.*)\.php$' to uri '/
abc.com/show/1052'
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f9e100/initial] (3) applying pattern '^/viewblog/(.+)/?$' to uri
'/abc.com/show/1052'
127.0.0.1 - - [23/Feb/2008:23:12:08 +0800] [localhost/sid#2bbfb0]
[rid#f9e100/initial] (1) pass through /abc.com/show/1052



anyone could lend me a hand?

 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
freech

External


Since: Feb 17, 2008
Posts: 8



(Msg. 2) Posted: Sat Feb 23, 2008 7:26 am
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>
> Configuration in httpd:
>
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^localhost$
> RewriteCond %{REQUEST_URI} !^/index\.php$
> RewriteCond %{REQUEST_URI} \.php$
> RewriteCond %{QUERY_STRING} &?tid=(.+)&?
> RewriteRule (.*)\.php$ $1/%1? [R]
> RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=$1[L]
> </IfModule>
>

sorry, I mistype here:
RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=
$1[L]
should be RewriteRule ^/show/(.+)/?$http://localhost/abc.com/show.php?
tid=$1[L]

 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
phantom

External


Since: Aug 23, 2007
Posts: 66



(Msg. 3) Posted: Sat Feb 23, 2008 1:04 pm
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"freech" <hifreedo.DeleteThis@gmail.com> wrote in message
news:50ace5db-858b-4af9-953a-041415b3e70f@q70g2000hsb.googlegroups.com...
> >
>> Configuration in httpd:
>>
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>> RewriteCond %{HTTP_HOST} ^localhost$
>> RewriteCond %{REQUEST_URI} !^/index\.php$
>> RewriteCond %{REQUEST_URI} \.php$
>> RewriteCond %{QUERY_STRING} &?tid=(.+)&?
>> RewriteRule (.*)\.php$ $1/%1? [R]
>> RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=$1[L]
>> </IfModule>
>>
>
> sorry, I mistype here:
> RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=
> $1[L]
> should be RewriteRule ^/show/(.+)/?$http://localhost/abc.com/show.php?
> tid=$1[L]

Not only are you making your life difficult for yourself by having rules in
your config that do the rewrite the other way round, by using a rewrite with
http://... on the RHS you are forcing an explicit redirect (as if you used
[R]) which your browser then sends back to apache and is matched by the
rules you have for going the other way.
Change this:
RewriteRule ^/show/(.+)/?$ http://localhost/abc.com/show.php?tid=$1 [L]
to be this:
RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]

and possibly think about removing the rules that do the rewrite the other
way round, giving this as the full config:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]
</IfModule>
 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
freech

External


Since: Feb 17, 2008
Posts: 8



(Msg. 4) Posted: Sun Feb 24, 2008 4:27 am
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi phantom,

yes, you right, on configuring these rules, spent hours from me, which
looks like really make simple things complex.

while I'm still want to take it to effect, because of 2 reasons:
1. want to make the web url friendly to searching engine.
2. want to make the url easily to be remembered by users, for e.g, if
I provide blog to registered users, they may have their own urls looks
like: www.abc.com/u/jacky

maybe there's other ways to achieve these 2 points I dont know?


On 2月24日, 上午12时21分, "phantom" <nob....DeleteThis@blueyonder.invalid> wrote:
> "freech" <hifre....DeleteThis@gmail.com> wrote in message
>
> news:50ace5db-858b-4af9-953a-041415b3e70f@q70g2000hsb.googlegroups.com...
>
>
>
>
>
> >> Configuration in httpd:
>
> >> <IfModule mod_rewrite.c>
> >> RewriteEngine On
> >> RewriteCond %{HTTP_HOST} ^localhost$
> >> RewriteCond %{REQUEST_URI} !^/index\.php$
> >> RewriteCond %{REQUEST_URI} \.php$
> >> RewriteCond %{QUERY_STRING} &?tid=(.+)&?
> >> RewriteRule (.*)\.php$ $1/%1? [R]
> >> RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=$1[L]
> >> </IfModule>
>
> > sorry, I mistype here:
> > RewriteRule ^/viewblog/(.+)/?$http://localhost/abc.com/show.php?tid=
> > $1[L]
> > should be RewriteRule ^/show/(.+)/?$http://localhost/abc.com/show.php?
> > tid=$1[L]
>
> Not only are you making your life difficult for yourself by having rules in
> your config that do the rewrite the other way round, by using a rewrite with
> http://... on the RHS you are forcing an explicit redirect (as if you used
> [R]) which your browser then sends back to apache and is matched by the
> rules you have for going the other way.
> Change this:
> RewriteRule ^/show/(.+)/?$http://localhost/abc.com/show.php?tid=$1[L]
> to be this:
> RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]
>
> and possibly think about removing the rules that do the rewrite the other
> way round, giving this as the full config:
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]
> </IfModule>
 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
phantom

External


Since: Aug 23, 2007
Posts: 66



(Msg. 5) Posted: Sun Feb 24, 2008 3:04 pm
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"freech" <hifreedo.TakeThisOut@gmail.com> wrote in message
news:dc52938c-6e58-4b64-878f-f1a317646c91@60g2000hsy.googlegroups.com...
> Hi phantom,
>
> yes, you right, on configuring these rules, spent hours from me, which
> looks like really make simple things complex.
>
> while I'm still want to take it to effect, because of 2 reasons:
> 1. want to make the web url friendly to searching engine.
> 2. want to make the url easily to be remembered by users, for e.g, if
> I provide blog to registered users, they may have their own urls looks
> like: www.abc.com/u/jacky
>
> maybe there's other ways to achieve these 2 points I dont know?

You appear to be overcomplicating the issue, this rule
> RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]
covers both your points.
 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
freech

External


Since: Feb 17, 2008
Posts: 8



(Msg. 6) Posted: Sun Feb 24, 2008 5:52 pm
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2月24日, 下午11时33分, "phantom" <nob... RemoveThis @blueyonder.invalid> wrote:
> "freech" <hifre... RemoveThis @gmail.com> wrote in message
>
> news:dc52938c-6e58-4b64-878f-f1a317646c91@60g2000hsy.googlegroups.com...
>
> > Hi phantom,
>
> > yes, you right, on configuring these rules, spent hours from me, which
> > looks like really make simple things complex.
>
> > while I'm still want to take it to effect, because of 2 reasons:
> > 1. want to make the web url friendly to searching engine.
> > 2. want to make the url easily to be remembered by users, for e.g, if
> > I provide blog to registered users, they may have their own urls looks
> > like: www.abc.com/u/jacky
>
> > maybe there's other ways to achieve these 2 points I dont know?
>
> You appear to be overcomplicating the issue, this rule> RewriteRule ^/show/(.+)/?$ /abc.com/show.php?tid=$1 [L]
>
> covers both your points.

thank you, for 1 more question:
how to do : www.abc.com/show.php?tid=1&bid=3&do=add into
www.abc.com/show/1/3/add?
 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
phantom

External


Since: Aug 23, 2007
Posts: 66



(Msg. 7) Posted: Mon Feb 25, 2008 6:16 am
Post subject: Re: mod_rewrite with 404 not found error at localhost [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"freech" <hifreedo DeleteThis @gmail.com> wrote in message
news:460eeea7-7b5b-443f-bc29-ffe32db09b43@i7g2000prf.googlegroups.com...
> thank you, for 1 more question:
> how to do : www.abc.com/show.php?tid=1&bid=3&do=add into
> www.abc.com/show/1/3/add?

I'm guessing you mean use www.abc.com/show/1/3/add
and internally rewrite to www.abc.com/show.php?tid=1&bid=3&do=add ?

RewriteRule ^/show/(.+)/(.+)/(.+)/?$ /abc.com/show.php?tid=$1&bid=$2&do=$3
[L]
should work, this might be safer
RewriteRule ^/show/([^/]+)/([^/]+)/({^/]+)/?$
/abc.com/show.php?tid=$1&bid=$2&do=$3 [L]
 >> Stay informed about: mod_rewrite with 404 not found error at localhost 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]