(.*)/members/ rewrite problem

Discuss practical ways rearrange URLs using mod_rewrite.

(.*)/members/ rewrite problem

Postby overflow » Mon Sep 15, 2008 4:51 am

I have a problem.

htdocs for adres.com
htdocs = /home/adres.com/htdocs

www.adres.com/(.*)/members/
to
htdocs/sourcedirectory/members/

I try but not worked

e.x:
www.address.com/ANIMALS/members/
www.address.com/ANIMALS/members/index.php
www.address.com/ANIMALS/members/css/style.css

Just this works.

Code: Select all
RewriteCond %{REQUEST_URI} ^/([-a-z0-9]+)/members/?$ [NC]
RewriteRule . /sourcedirectory/members/index.php [QSA,L]
overflow
 
Posts: 19
Joined: Thu Oct 12, 2006 2:02 am
Location: Turkey

Postby richardk » Mon Sep 15, 2008 10:56 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Don't rewrite /sourcedirectory/members (to stop loops).
RewriteCond %{REQUEST_URI} !^/sourcedirectory/members(/.*)?$ [NC]
# Pass on anything after members/ ($2).
RewriteRule ^[-a-z0-9]+/members(/(.*))?$ /sourcedirectory/members/$2 [NC,QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby overflow » Mon Sep 15, 2008 11:14 pm

I tried but didn't work. Just 404 file not found
overflow
 
Posts: 19
Joined: Thu Oct 12, 2006 2:02 am
Location: Turkey

Postby richardk » Tue Sep 16, 2008 11:42 am

What URL did you go to?
What file should have been shown?
Where are you putting the mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby overflow » Wed Sep 17, 2008 12:16 am

WEBHOST_DIR = /home/adres.com/htdocs/
SOURCE_DIR = /home/adres.com/htdocs/SOURCEDIR/

http://www.adres.com/animal/members/ -> SOURCEDIR/members/

All rewrite rules
Code: Select all
Options +FollowSymLinks
RewriteEngine on


# Don't rewrite /sourcedirectory/members (to stop loops).
RewriteCond %{REQUEST_URI} !^/SOURCEDIR/members(/.*)?$ [NC]
# Pass on anything after members/ ($2).
RewriteRule ^[-a-z0-9]+/members(/(.*))?$ /SOURCEDIR/members/$2 [NC,QSA,L]

RewriteRule   ^/(.*)/(.*)-f-([0-9]*)-([0-9]*).html$   /SOURCEDIR/feed.php?directory=$1&feedid=$3&linkid=$4 [L]
RewriteRule   ^/(.*)/(.*)-s-([0-9]*).html$   /SOURCEDIR/single.php?directory=$1&name=$2&id=$3 [L]
RewriteRule   ^/(.*)/(.*)-t-([0-9]*).html$   /SOURCEDIR/tag.php?directory=$1&name=$2&id=$3 [L]

RewriteRule   ^/(.*)/(.*)-c-([0-9]*).html$   /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3 [L]
RewriteRule   ^/(.*)/(.*)-k-([0-9]*).html$   /SOURCEDIR/index.php?directory=$1&do=keywords&words=$2&id=$3 [L]
RewriteRule   ^/(.*)/(.*)-c-([0-9]*)-p-([0-9]*).html$   /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3&start=$4 [L]
RewriteRule   ^/(.*)/top-rank([0-9]{1,2}).html$   /SOURCEDIR/index.php?directory=$1&do=top-rank&pr=$2 [L]

RewriteCond %{REQUEST_URI} !^.*/members/.*$
RewriteRule   ^/(.*)/(([a-z]|-)*).html$   /SOURCEDIR/index.php?directory=$1&do=$2 [L]

RewriteCond   %{REQUEST_URI} !^/(uyeler|members|arama|search|tema|class|themes|logs|cgi-bin)(/.*)?$ [NC]
RewriteCond   %{REQUEST_URI} ^/([-a-z0-9]+)/([^/]+)\.html$ [NC,OR]
RewriteCond   %{REQUEST_URI} ^/([-a-z0-9]+)/?$ [NC]
RewriteRule   . /SOURCEDIR/index.php?directory=%1 [QSA,L]



I tried urls

http://www.adres.com/animal/members/ [404]
http://www.adres.com/animal/members/index.php [404]
http://www.adres.com/animal/members/include/style.css [404]

my old rewrite question

richardk wrote:What URL did you go to?
What file should have been shown?
Where are you putting the mod_rewrite?
overflow
 
Posts: 19
Joined: Thu Oct 12, 2006 2:02 am
Location: Turkey

Postby richardk » Fri Sep 19, 2008 7:08 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/SOURCEDIR/members(/[^/]+)?$ [NC]
RewriteRule ^/[^/]+/members(/(.*))?$ /SOURCEDIR/members/$2 [NC,QSA,L]

RewriteRule ^/([^/]+)/([^/]+)-f-([0-9]+)-([0-9]+)\.html$   /SOURCEDIR/feed.php?directory=$1&feedid=$3&linkid=$4         [L]
RewriteRule ^/([^/]+)/([^/]+)-s-([0-9]+)\.html$            /SOURCEDIR/single.php?directory=$1&name=$2&id=$3             [L]
RewriteRule ^/([^/]+)/([^/]+)-t-([0-9]+)\.html$            /SOURCEDIR/tag.php?directory=$1&name=$2&id=$3                [L]
RewriteRule ^/([^/]+)/([^/]+)-c-([0-9]+)\.html$            /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3             [L]
RewriteRule ^/([^/]+)/([^/]+)-k-([0-9]+)\.html$            /SOURCEDIR/index.php?directory=$1&do=keywords&words=$2&id=$3 [L]
RewriteRule ^/([^/]+)/([^/]+)-c-([0-9]+)-p-([0-9]+)\.html$ /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3&start=$4    [L]
RewriteRule ^/([^/]+)/top-rank([0-9]{1,2}).html$           /SOURCEDIR/index.php?directory=$1&do=top-rank&pr=$2          [L]

RewriteCond %{REQUEST_URI} !^/[^/]+/members(/.*)?$
RewriteRule ^/([^/]+)/(([a-z]|-)*).html$ /SOURCEDIR/index.php?directory=$1&do=$2 [L]

RewriteCond %{REQUEST_URI} ^/([-a-z0-9]+)(/([^/]+\.html)?)?$ [NC]
RewriteRule !^/(uyeler|members|arama|search|tema|class|themes|logs|cgi-bin)(/.*)?$ /SOURCEDIR/index.php?directory=%1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby overflow » Mon Sep 22, 2008 12:20 am

It is work. Thanks richardk.

Does that line my fix problem?

Code: Select all
RewriteCond %{REQUEST_URI} ^/([-a-z0-9]+)(/([^/]+\.html)?)?$ [NC]
RewriteRule !^/(uyeler|members|arama|search|tema|class|themes|logs|cgi-bin)(/.*)?$ /SOURCEDIR/index.php?directory=%1 [QSA,L]
overflow
 
Posts: 19
Joined: Thu Oct 12, 2006 2:02 am
Location: Turkey

Postby richardk » Tue Sep 23, 2008 11:50 am

That is a shorter version of
Code: Select all
RewriteCond   %{REQUEST_URI} !^/(uyeler|members|arama|search|tema|class|themes|logs|cgi-bin)(/.*)?$ [NC]
RewriteCond   %{REQUEST_URI} ^/([-a-z0-9]+)/([^/]+)\.html$ [NC,OR]
RewriteCond   %{REQUEST_URI} ^/([-a-z0-9]+)/?$ [NC]
RewriteRule   . /SOURCEDIR/index.php?directory=%1 [QSA,L]


To be honest i'm not certain what fixed it for you. It should be this anyway
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/SOURCEDIR/members(/.*)?$ [NC]
RewriteRule ^/[^/]+/members(/(.*))?$ /SOURCEDIR/members/$2 [NC,QSA,L]

RewriteRule ^/([^/]+)/([^/]+)-f-([0-9]+)-([0-9]+)\.html$   /SOURCEDIR/feed.php?directory=$1&feedid=$3&linkid=$4         [L]
RewriteRule ^/([^/]+)/([^/]+)-s-([0-9]+)\.html$            /SOURCEDIR/single.php?directory=$1&name=$2&id=$3             [L]
RewriteRule ^/([^/]+)/([^/]+)-t-([0-9]+)\.html$            /SOURCEDIR/tag.php?directory=$1&name=$2&id=$3                [L]
RewriteRule ^/([^/]+)/([^/]+)-c-([0-9]+)\.html$            /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3             [L]
RewriteRule ^/([^/]+)/([^/]+)-k-([0-9]+)\.html$            /SOURCEDIR/index.php?directory=$1&do=keywords&words=$2&id=$3 [L]
RewriteRule ^/([^/]+)/([^/]+)-c-([0-9]+)-p-([0-9]+)\.html$ /SOURCEDIR/index.php?directory=$1&name=$2&dir=$3&start=$4    [L]
RewriteRule ^/([^/]+)/top-rank([0-9]{1,2})\.html$          /SOURCEDIR/index.php?directory=$1&do=top-rank&pr=$2          [L]

RewriteCond %{REQUEST_URI} !^/[^/]+/members(/.*)?$
RewriteRule ^/([^/]+)/([-a-z]+)\.html$ /SOURCEDIR/index.php?directory=$1&do=$2 [L]

RewriteCond %{REQUEST_URI} ^/([-a-z0-9]+)(/([^/]+\.html)?)?$ [NC]
RewriteRule !^/(uyeler|members|arama|search|tema|class|themes|logs|cgi-bin)(/.*)?$ /SOURCEDIR/index.php?directory=%1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 18 guests

cron