Forum Moderators: phranque

Message Too Old, No Replies

once again about rewrite rules

i need assistance

         

alexo

9:49 am on Aug 27, 2005 (gmt 0)

10+ Year Member



in one of posts (unfortunately now it's in archive and i cann't post there) i ask the question

my url-s are right this

domain.com/comments.php?id=1777_0_1_0_C
domain.com/comments.php?id=1777_0_1_0_C13

how can i rewrite it to

domain.com/more/1777_0_1_0_C/

and get answer from jdMorgan:

to do this

RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9_]+)/$ /more/$1/ [R=301,L]
RewriteRule ^comments/([A-Za-z0-9_]+)$ /more/$1/ [R=301,L]

more than 3 months it's work find, until yesterday, when i check that rewrite rules don;'t work
and u can access this site domain.com/comments.php?id=1777_0_1_0_C without any problem

i contact my hoster and ask did they do any changes in apache configuration and get answer, that they don't change durign last 3-4 months.!

i don't understand, what can be the reason of this?
why i works 2-3 months and now it don't work

my whole htaccess file is like this (may be some lines cause any problem?


RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteRule ^stuff/([A-Za-z0-9_]+)/$ /more/$1/ [R=301,L]
RewriteRule ^stuff/([A-Za-z0-9_]+)$ /more/$1/ [R=301,L]
RewriteRule ^comments/([A-Za-z0-9_]+)/$ /more/$1/ [R=301,L]
RewriteRule ^comments/([A-Za-z0-9_]+)$ /more/$1/ [R=301,L]
RewriteRule ^articles_comments/([A-Za-z0-9_]+)/$ /articles_more/$1/ [R=301,L]
RewriteRule ^articles_comments/([A-Za-z0-9_]+)$ /articles_more/$1/ [R=301,L]

Redirect 301 /nnews/index.php http://www.domain.com/
Redirect 301 /eng/index.html http://www.domain.com/eng/index.php
DirectoryIndex index.php
Redirect 301 /index.html http://www.domain.com/index.php
Redirect 301 /index.htm http://www.domain.com/index.php

deny from 128.138.134.9
deny from 213.171.38.21

alexo

11:21 am on Aug 27, 2005 (gmt 0)

10+ Year Member



sorry last lines

<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 128.138.134.9
deny from 213.171.38.21

alexo

11:23 am on Aug 27, 2005 (gmt 0)

10+ Year Member



i disable Phpsuexec, but even this don't help :-(

jdMorgan

4:06 pm on Aug 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you had working code and it stopped working, and you made no changes, then your host changed something. Code just doesn;t stop working for no reason. Please post the URL or thread title that you were referring to above - The code in the thread I found does not match the code you posted here.

Jim

alexo

11:17 pm on Aug 27, 2005 (gmt 0)

10+ Year Member



hello jdMorgan

here is url to that thread
[webmasterworld.com...]

starting post:#4

alexo

11:11 am on Aug 31, 2005 (gmt 0)

10+ Year Member



Hello all

sorry, for my previous post . pls don't read it, there are errors

i'm tring to rewrite (htaccess) this url-s

[localhost...]

to this

[localhost...]
=======================================

as a basic i take jdMorgan's instructions and this article sitepoint.com/article/guide-url-rewriting/2

but without any success

create 2 different lines,

RewriteRule /more/([A-Za-z0-9_]+) /more.php?id=$1 [R=301,L] 

RewriteRule /more/([A-Za-z0-9_]+)[b]/$[/b] /more.php?id=$1 [R=301,L] 

but non of them don't work.

can u tell me, what i'm doing wrong?

alexo

8:24 pm on Sep 1, 2005 (gmt 0)

10+ Year Member



any advise PLEASE! :-(

jdMorgan

4:21 am on Sep 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You stated that you had working code and it stopped working. This means that your host changed something. Therefore, I assumed that you would contact your host and find out what was changed. If that is not the case, then...

In .htaccess:


RewriteRule ^more/([a-z0-9_]+)/?$ http://%{HTTP_HOST}/more.php?id=$1 [NC,R=301,L]

[NC] makes the match case-insensitive, so it is not necessary to have both [a-z] and [A-Z].

Jim

alexo

12:38 pm on Sep 2, 2005 (gmt 0)

10+ Year Member



>>>You stated that you had working code and it stopped working. This means that your host changed something. Therefore, I assumed that you would contact your host and find out what was changed. If that is not the case, then...

Yess, u are right.
but first of all i have mistaken.
1. i haven't any code in htaccess file to redirect
more.php to /more/

the only code that i had is redirect from
/comment/ to /more/

it's what i add in my msg #:1

RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9_]+)/$ /more/$1/ [R=301,L]
RewriteRule ^comments/([A-Za-z0-9_]+)$ /more/$1/ [R=301,L]

2. yes, that's true, that it work (the code above) and suddenly don't work. (getting 501 or 504 error)
of course i contact my hoster and whole day, they are investigating to find the reason of this.
as they told, they don't did any server configuration changes on server for last 2 months.
it's a solid and very popular VPS hosting company, so i believe them

don't ask my the reason, what's the reason of this.
i don't know :-(
during all this time (more thant 8-9 hours) i make a lot of changes in my htaccess file without any result.

and as suddenly it don't work, as suddenly he start work. ~

---------------
so , as i told above i haven't any redirect
from more.php to /more/

---------------
now about code that u give me

RewriteRule ^more/([a-z0-9_]+)/?$ [%{HTTP_HOST}...] [NC,R=301,L]

it don't work.
any changes and any error.

the only code that work in my case , is

rewriteRule ^more\.php$ [%{HTTP_HOST}...] [R=301,L]

it redirect

more.php?id=503_0_3_0_M
to
more/?id=503_0_3_0_M

:-(
but i cann't find any way to remove this [?id=]

jd01

5:42 pm on Sep 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To remove the original query string, append a blank one to the end:

RewriteRule ^more\.php$ http://%{HTTP_HOST}/chewnet1/more$1/? [R=301,L]

Justin

alexo

12:59 am on Sep 3, 2005 (gmt 0)

10+ Year Member



no, unfortunately it doesn't help

=======
rewriteRule ^more\.php$ [%{HTTP_HOST}...] [R=301,L]

it redirect

more.php?id=503_0_3_0_M
to
more/?id=503_0_3_0_M

==========
but when i add? as u advise

more.php?id=503_0_3_0_M
redirected to

more/

i loss not only query string, but all after this too :-(

jd01

3:22 am on Sep 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where did you want it to go?

The rule you have posted refers to back-reference 1 ($1), but there is no $1 defined, so it redirected correctly... sorry I did not point that out earlier - I just copied and pasted what you had.

What are you trying to do? Please, post an example of the format you would like more/something to be redirected to.

Justin

alexo

1:17 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



Hello

here is , what i trying to do

to redirect such files

[domain.com...]

to

http://www.domain.com/more/503_0_3_0_M/

================
just now i get only

[domain.com...]

with redirect =>

rewriteRule ^more\.php$ [%{HTTP_HOST}...][R=301,L]

or

[domain.com...]

with redirect

RewriteRule ^more\.php$ [%{HTTP_HOST}...] [R=301,L]

alexo

1:19 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



Hello

here is , what i trying to do

to redirect such files

[domain.com...]

to

http://www.domain.com/more/503_0_3_0_M/

================
just now i get only

[domain.com...]

with redirect =>

rewriteRule ^more\.php$ [%{HTTP_HOST}...] [R=301,L]

or

[domain.com...]

with redirect (as u mentioned)

RewriteRule ^more\.php$ [%{HTTP_HOST}...] [R=301,L]

thank you

jd01

5:08 pm on Sep 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you are going the wrong way...

I would start with this post and then go from there:

[webmasterworld.com...]

Basically, you will need to change your links and then use a simple mod_rewrite to rewrite the information from your script to the new locations.

Wish I could be more help, but you really can't do anything until you make some changes to the structure of your site.

Justin