Page 1 of 1

mod_rewrite help please

Posted: Sat Oct 11, 2008 6:47 am
by malcolmboston
Im currently having some serious problems with mod_rewrite or maybe im just not understanding it right.....

Code: Select all

 
Rewriterule '^mens/item/(.*)/(.*)/(.*)/(.*) mens-item-(.*)-(.*)-(.*)-(.*).html [R=301, NC, L]
 
Ive added this line to my mod_rewrite file but i get an internal server error when its turned on.

basically i want this page:
http://www.redsquareclothing.co.uk/mens ... jma-Jacket
to automatically redirect using a 301 to this page:
http://www.redsquareclothing.co.uk/mens ... acket.html

Any help or nod in the right direction would be much appreciated.

edit: :? @ shortened URL

Regards, Mal

Re: mod_rewrite help please

Posted: Sat Oct 11, 2008 6:56 am
by onion2k
I think you need to backslash the forward slashes, and the second part should be using references rather than .* ... eg

Code: Select all

Rewriterule '^mens\/item\/(.*)\/(.*)\/(.*)\/(.*)\/? mens-item-($1)-($2)-($3)-($4).html [R=301, NC, L]
The \/? at the end of the first part is just in case the user pops a / on the end of the URL.

Re: mod_rewrite help please

Posted: Sat Oct 11, 2008 7:09 am
by malcolmboston
Unfortunately that gives me an internal server error as well and i dont know anyway to get any error messages that can shed light on the error.

Just in case it helps, my full .htaccess file:

Code: Select all

 
ErrorDocument 404 http://www.redsquareclothing.co.uk/404.php
 
AddType x-mapp-php4 .php
RewriteEngine on
ReWriteBase /
RewriteRule ^mens/sale$ showSale.php [L]
RewriteRule ^mens/site-map$ sitemap.php [L]
RewriteRule ^mens/brands$ brandList.php [L]
 
RewriteRule ^mens/item/([0-9]+)/(.*)/(.*)$ showItem.php?stockCode=$1 [L]
RewriteRule ^mens/cat/([0-9]+)/(.*)/([0-9]+)/(.*)$ showCategories.php?catID=$1&page=$3&amount=$4 [L]
RewriteRule ^mens/brand/([0-9]+)/(.*)$ showBrand.php?brandID=$1 [L]
RewriteRule ^mens/brand_cat/([0-9]+)/(.*)/(.*)/(.*)$ showListings.php?brandID=$1&catID=$2 [L]
RewriteRule ^article/([0-9]+)/(.*)$ readArticle.php?id=$1 [L]
RewriteRule ^mens/sale/([0-9]+)/(.*)$ showSale.php?catID=$1 [L]
 
Options +FollowSymlinks
rewritecond %{http_host} ^redsquareclothing.co.uk [nc]
rewriterule ^(.*)$ http://www.redsquareclothing.co.uk/$1 [r=301,nc]
 
 
RewriteCond %{HTTP_HOST} ^(www.)?redsquareclothing.com
RewriteRule ^(.*) http://www.redsquareclothing.co.uk/$1 [R=301,L]
 

Re: mod_rewrite help please

Posted: Sat Oct 11, 2008 8:05 am
by onion2k
Ah.. cut and paste error ... there's an apostrophe at the start of the rule that shouldn't be there.

Re: mod_rewrite help please

Posted: Sat Oct 11, 2008 9:07 am
by malcolmboston
same :banghead:

Code: Select all

 
ErrorDocument 404 http://www.redsquareclothing.co.uk/404.php
 
AddType x-mapp-php4 .php
RewriteEngine on
ReWriteBase /
RewriteRule ^mens/sale$ showSale.php [L]
RewriteRule ^mens/site-map$ sitemap.php [L]
RewriteRule ^mens/brands$ brandList.php [L]
 
RewriteRule ^mens/item/([0-9]+)/(.*)/(.*)$ showItem.php?stockCode=$1 [L]
RewriteRule ^mens/cat/([0-9]+)/(.*)/([0-9]+)/(.*)$ showCategories.php?catID=$1&page=$3&amount=$4 [L]
RewriteRule ^mens/brand/([0-9]+)/(.*)$ showBrand.php?brandID=$1 [L]
RewriteRule ^mens/brand_cat/([0-9]+)/(.*)/(.*)/(.*)$ showListings.php?brandID=$1&catID=$2 [L]
RewriteRule ^article/([0-9]+)/(.*)$ readArticle.php?id=$1 [L]
RewriteRule ^mens/sale/([0-9]+)/(.*)$ showSale.php?catID=$1 [L]
 
Options +FollowSymlinks
rewritecond %{http_host} ^redsquareclothing.co.uk [nc]
rewriterule ^(.*)$ http://www.redsquareclothing.co.uk/$1 [r=301,nc]
 
 
RewriteCond %{HTTP_HOST} ^(www.)?redsquareclothing.com
RewriteRule ^(.*) http://www.redsquareclothing.co.uk/$1 [R=301,L]
 
 
Rewriterule ^mens\/item\/(.*)\/(.*)\/(.*)\/(.*)\/? mens-item-($1)-($2)-($3)-($4).html [R=301, NC, L]
 
is there anyway to actually find the cause of the error?