Forum Moderators: phranque
my url-s are right thisdomain.com/comments.php?id=1777_0_1_0_C
domain.com/comments.php?id=1777_0_1_0_C13how 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
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?
In .htaccess:
RewriteRule ^more/([a-z0-9_]+)/?$ http://%{HTTP_HOST}/more.php?id=$1 [NC,R=301,L]
Jim
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=]
=======
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 :-(
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
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]
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
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