Change path

Discuss practical ways rearrange URLs using mod_rewrite.

Postby Pablo90 » Tue Nov 25, 2008 11:00 am

It doesn't work yet...I'm sorry..

PS: can I automatically add the final slash "/"?
If a guest doesn't put the slash at the end of the url, it works but the code automatically add it.. Sorry if I change subject, but so I kill two birds with a stone :D
Pablo90
 
Posts: 18
Joined: Thu Oct 09, 2008 7:45 am

Postby richardk » Tue Nov 25, 2008 2:01 pm

It doesn't work yet.

Please explain "doesn't work". What URL are you visiting? What is happening? What should happen?

PS: can I automatically add the final slash "/"?
If a guest doesn't put the slash at the end of the url, it works but the code automatically add it.

To which URLs?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Pablo90 » Wed Dec 03, 2008 9:41 am

richardk wrote:
It doesn't work yet.

Please explain "doesn't work". What URL are you visiting? What is happening? What should happen?

PS: can I automatically add the final slash "/"?
If a guest doesn't put the slash at the end of the url, it works but the code automatically add it.

To which URLs?

Sorry this website/server was down (I think I can say it in this way, in Italian to explain a not working server we say "È in down" so I thought that in English people say "server was down". I hope this isn't a bad word :D)

Anyway with "doesn't work" I mean that nothing changed, and I would like to add the slashes to all urls (if there isn't yet)
Pablo90
 
Posts: 18
Joined: Thu Oct 09, 2008 7:45 am

Postby richardk » Wed Dec 03, 2008 9:47 am

Sorry this website/server was down (I think I can say it in this way, in Italian to explain a not working server we say "È in down" so I thought that in English people say "server was down". I hope this isn't a bad word )

That is correct.

Anyway with "doesn't work" I mean that nothing changed, and I would like to add the slashes to all urls (if there isn't yet)

Try
Code: Select all
AddDefaultCharset iso-8859-1
Options +FollowSymLinks

# Error Pages
ErrorDocument 401 /?act=error&e=401
ErrorDocument 403 /?act=error&e=403
ErrorDocument 404 /?act=error&e=404
ErrorDocument 500 /?act=error&e=500


<IfModule mod_rewrite.c>
  RewriteEngine On

  # Qui redirect per telefilm e notizie
  RewriteRule ^greeek(/(.*))?$ /greek/$2 [R=301,L]

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

  # BEGIN Gruppo Modulo Rewrite
  RewriteRule ^([-a-z0-9]+)/$                                index.php?act=$1&tid=$1                        [NC,L]
  RewriteRule ^([-a-z0-9]+)/pagina-([0-9]+)/$                index.php?act=$1&tid=$1&page=$2                [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/$                   index.php?act=telefilm&tid=$1&mod=$2           [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/stagione-([0-9]+)/$ index.php?act=telefilm&tid=$1&mod=$2&season=$3 [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/([-a-z0-9]+)/$      index.php?act=show&slug=$3                     [NC,L]
  # END Gruppo Modulo Rewrite
</IfModule>

# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
  Order deny,allow
  Deny from all
  Allow from all
</Limit>

<Limit PUT DELETE>
  Order deny,allow
  Deny from all
</Limit>

AuthName telefilmsnetwork.com
AuthUserFile /home/telefilm/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/telefilm/public_html/_vti_pvt/service.grp


If that does not work, try replacing
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f

with
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Pablo90 » Wed Dec 03, 2008 10:35 am

richardk wrote:
Sorry this website/server was down (I think I can say it in this way, in Italian to explain a not working server we say "È in down" so I thought that in English people say "server was down". I hope this isn't a bad word )

That is correct.

Anyway with "doesn't work" I mean that nothing changed, and I would like to add the slashes to all urls (if there isn't yet)

Try
Code: Select all
AddDefaultCharset iso-8859-1
Options +FollowSymLinks

# Error Pages
ErrorDocument 401 /?act=error&e=401
ErrorDocument 403 /?act=error&e=403
ErrorDocument 404 /?act=error&e=404
ErrorDocument 500 /?act=error&e=500


<IfModule mod_rewrite.c>
  RewriteEngine On

  # Qui redirect per telefilm e notizie
  RewriteRule ^greeek(/(.*))?$ /greek/$2 [R=301,L]

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

  # BEGIN Gruppo Modulo Rewrite
  RewriteRule ^([-a-z0-9]+)/$                                index.php?act=$1&tid=$1                        [NC,L]
  RewriteRule ^([-a-z0-9]+)/pagina-([0-9]+)/$                index.php?act=$1&tid=$1&page=$2                [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/$                   index.php?act=telefilm&tid=$1&mod=$2           [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/stagione-([0-9]+)/$ index.php?act=telefilm&tid=$1&mod=$2&season=$3 [NC,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/([-a-z0-9]+)/$      index.php?act=show&slug=$3                     [NC,L]
  # END Gruppo Modulo Rewrite
</IfModule>

# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
  Order deny,allow
  Deny from all
  Allow from all
</Limit>

<Limit PUT DELETE>
  Order deny,allow
  Deny from all
</Limit>

AuthName telefilmsnetwork.com
AuthUserFile /home/telefilm/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/telefilm/public_html/_vti_pvt/service.grp


If that does not work, try replacing
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f

with
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$


I tried both of them, but it doesn't redirect at all...
Pablo90
 
Posts: 18
Joined: Thu Oct 09, 2008 7:45 am

Postby richardk » Thu Dec 04, 2008 9:26 am

The other rules are working, right?

Try
Code: Select all
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

and
Code: Select all
RewriteCond %{REQUEST_URI} !/$
RewriteRule .* %{REQUEST_URI}/ [R=301,L]

instead of
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Pablo90 » Thu Dec 04, 2008 10:37 am

I put:
Code: Select all
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{REQUEST_URI} !/$
RewriteRule .* %{REQUEST_URI}/ [R=301,L][/code]

instead of

Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
[/quote]
right? because now it doesn't work the other codes..
Pablo90
 
Posts: 18
Joined: Thu Oct 09, 2008 7:45 am

Postby richardk » Thu Dec 04, 2008 2:14 pm

I meant try one at a time.

Also try
Code: Select all
AddDefaultCharset iso-8859-1
Options +FollowSymLinks

# Error Pages
ErrorDocument 401 /?act=error&e=401
ErrorDocument 403 /?act=error&e=403
ErrorDocument 404 /?act=error&e=404
ErrorDocument 500 /?act=error&e=500


<IfModule mod_rewrite.c>
  RewriteEngine On

  # Qui redirect per telefilm e notizie
  RewriteRule ^greeek(/(.*))?$ /greek/$2 [R=301,L]

  # BEGIN Gruppo Modulo Rewrite
  RewriteRule ^([-a-z0-9]+)$ /$1/ [NC,R=301,L]
  RewriteRule ^([-a-z0-9]+)/$ /index.php?act=$1&tid=$1 [NC,QSA,L]

  RewriteRule ^([-a-z0-9]+)/pagina-([0-9]+)$ /$1/pagina-$2/ [NC,R=301,L]
  RewriteRule ^([-a-z0-9]+)/pagina-([0-9]+)/$ /index.php?act=$1&tid=$1&page=$2 [NC,QSA,L]

  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)$ /$1/$2/ [NC,R=301,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/$ index.php?act=telefilm&tid=$1&mod=$2 [NC,QSA,L]

  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/stagione-([0-9]+)$ /$1/$2/stagione-$3/ [NC,R=301,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/stagione-([0-9]+)/$ /index.php?act=telefilm&tid=$1&mod=$2&season=$3 [NC,QSA,L]

  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/([-a-z0-9]+)$ /$1/$2/$3/ [NC,R=301,L]
  RewriteRule ^([-a-z0-9]+)/([-a-z0-9]+)/([-a-z0-9]+)/$ /index.php?act=show&slug=$3 [NC,QSA,L]
  # END Gruppo Modulo Rewrite
</IfModule>

# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
  Order deny,allow
  Deny from all
  Allow from all
</Limit>

<Limit PUT DELETE>
  Order deny,allow
  Deny from all
</Limit>

AuthName telefilmsnetwork.com
AuthUserFile /home/telefilm/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/telefilm/public_html/_vti_pvt/service.grp
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Pablo90 » Fri Dec 05, 2008 2:31 pm

I tried your last solution and it works. I mean this:
Code: Select all
  # Qui redirect per telefilm e notizie
  RewriteRule ^greeek(/(.*))?$ /greek/$2 [R=301,L]


It add the final slash if I write "greeek" without it, but if I write the correct url that is "greek" it doesn't add anything.
Can I add the final slashes to all my urls?

thank you
Pablo90
 
Posts: 18
Joined: Thu Oct 09, 2008 7:45 am

Postby richardk » Sat Dec 06, 2008 8:36 am

Add
Code: Select all
RewriteRule ^greek$ /greek/ [R=301,L]

after
Code: Select all
RewriteEngine On
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

PreviousNext

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 1 guest

cron