some deficiencies

Discuss practical ways rearrange URLs using mod_rewrite.

some deficiencies

Postby lavinya » Thu Apr 30, 2009 11:13 pm

I have a php script. script have a url mod_rewrite for this scriptte. Htaccess file is available. Url s looks like this:


Want to be sure:
1.
Code: Select all
/free-recipe/beef/radish-explosion/3/index.html

I want this address in the following way:
Code: Select all
/beef/radish-explosion-3/

if this address is entered for the end of the index.html or index.php with 301
Code: Select all
/beef/radish-explosion-3/
I want to direct it.
However, in the same way
Code: Select all
/bEef/Radish-ExplosioN-3/
large letters at this address is entered automatically with the 301
Code: Select all
/beef/radish-explosion-3/
I want to direct it. Because the big enter the letter is opened.

2.
Code: Select all
/beef/radish-explosion-3/
to this address at the end / I want to receive the automated sign. That is / are entered in this way
Code: Select all
/beef/radish-explosion-3
to
Code: Select all
/beef/radish-explosion-3/
I want to be like.

3. It seems like this category is to address:
Code: Select all
/category/beef/51/1/index.html

I also address this category I want to be in the following way:
Code: Select all
/beef/51-1/


If this address also this:
Code: Select all
/beef/51-1/index.html
or index.php to the end of the value
Code: Select all
has been entered;
/beef/51-1/
301 to this address I want to be guided by the code.

4. If the category is called address is as follows:
Code: Select all
/beef/

301 code with it
Code: Select all
/beef/51-1/
I want to be redirected to address.

Incorrect or incomplete address, error code 404 must be given in writing. In large letters with Current version is open, opens in lower case letters, enter additional words in the open it is wrong to me. This is the duplicate content is a redundancy.

Thank you in advance. Sorry my english not enought. if you help me i will be happy. thanks.

My .htaccess:
Code: Select all
# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

# Prevent directory browsing
IndexIgnore */*

# Set the default handler
DirectoryIndex index.php

# Maian Recipe rewrite rules
# If your server displays a 404 and supports htaccess, you might need to uncomment
# the next line and remove the IfModule rule below..
# RewriteBase /
RewriteRule ^(contact-us|about-us|add-recipe|rss-feed|404).html$ index.php?p=$1
RewriteRule ^index.html$ index.php
RewriteRule ^print/(.*)/index.html$ index.php?p=print&recipe=$1 [nc]
RewriteRule ^rss-cat-feed/(.*)/index.html index.php?p=rss-cat-feed&cat=$1 [nc]
RewriteRule ^tell-a-friend/(.*)/index.html$ index.php?p=tell-a-friend&recipe=$1 [nc]
RewriteRule ^contact-recipe/(.*)/index.html$ index.php?p=contact-recipe&recipe=$1 [nc]
RewriteRule ^add-recipe/(.*)/index.html$ index.php?p=add-recipe&cat=$1 [nc]
RewriteRule ^print/(.*)/index.html$ index.php?p=print&id=$1 [nc]
RewriteRule ^category/(.*)/(.*)/(.*)/index.html$ index.php?p=category&cat=$2&next=$3 [nc]
RewriteRule ^category/(.*)/(.*)/(.*)/(.*)/index.html$ index.php?p=category&cat=$3&next=$4 [nc]
RewriteRule ^free-recipe/(.*)/(.*)/(.*)/index.html$ index.php?p=recipe&recipe=$3 [nc]
RewriteRule ^search-free-recipes/(.*)/(.*)/(.*)/index.html$ index.php?p=search-free-recipes&keys=$1&cat=$2&next=$3 [nc]
#RewriteRule ^rating/(.*)/(.*)/(.*)/(.*)/(.*)/index.html$ index.php?p=rating&rsystem=rbar&r=$1&j=$2&q=$3&t=$4&c=$5 [nc]

# URL rewrite rules
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>


script demo:
http://www.maianscriptworld.co.uk/php/d ... index.html
script download: http://www.maianscriptworld.co.uk/free- ... index.html
lavinya
 
Posts: 6
Joined: Wed Apr 29, 2009 11:55 pm

Postby richardk » Fri May 01, 2009 11:28 am

/free-recipe/beef/radish-explosion/3/index.html

I want this address in the following way:
/beef/radish-explosion-3/

if this address is entered for the end of the index.html or index.php with 301
/beef/radish-explosion-3/
I want to direct it.

/beef/radish-explosion-3
to
Code:
/beef/radish-explosion-3/
I want to be like.

3. It seems like this category is to address:
/category/beef/51/1/index.html

I also address this category I want to be in the following way:
/beef/51-1/

If this address also this:
/beef/51-1/index.html
or index.php to the end of the value
has been entered;
/beef/51-1/
301 to this address I want to be guided by the code.

Try
Code: Select all
IndexIgnore */*
DirectoryIndex index.php


<IfModule mod_rewrite.c>
   RewriteEngine On

   # Remove index.php, index.html and index.htm.
   RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(php|html?)\  [NC]
   RewriteRule ^(.+/)?index\.(php|html?)$ /%1 [R=301,L]

   RewriteRule ^(contact-us|about-us|add-recipe|rss-feed|404)\.html$ /index.php?p=$1 [QSA,L]

   RewriteRule ^print/([^/]+)/?$          /index.php?p=print&recipe=$1          [NC,L]
   RewriteRule ^rss-cat-feed/([^/]+)/?$   /index.php?p=rss-cat-feed&cat=$1      [NC,L]
   RewriteRule ^tell-a-friend/([^/]+)/?$  /index.php?p=tell-a-friend&recipe=$1  [NC,L]
   RewriteRule ^contact-recipe/([^/]+)/?$ /index.php?p=contact-recipe&recipe=$1 [NC,L]
   RewriteRule ^add-recipe/([^/]+)/?$     /index.php?p=add-recipe&cat=$1        [NC,L]
   RewriteRule ^print/([^/]+)/?$          /index.php?p=print&id=$1              [NC,L]

   RewriteRule ^.+/([0-9]+)-([0-9]+)/?$   /index.php?p=category&cat=$1&next=$2  [L]

   RewriteRule ^[^/]+/[^/]+-(0-9]+)$  /$0/                          [R=301,L]
   RewriteRule ^[^/]+/[^/]+-(0-9]+)/$ /index.php?p=recipe&recipe=$3 [L]

   RewriteRule ^search-free-recipes/(.*)/(.*)/(.*)/index.html$ index.php?p=search-free-recipes&keys=$1&cat=$2&next=$3 [nc]
   #RewriteRule ^rating/(.*)/(.*)/(.*)/(.*)/(.*)/index.html$ index.php?p=rating&rsystem=rbar&r=$1&j=$2&q=$3&t=$4&c=$5 [nc]

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ /index.php [QSA,L]
</IfModule>


However, in the same way
/bEef/Radish-ExplosioN-3/
large letters at this address is entered automatically with the 301
/beef/radish-explosion-3/
I want to direct it. Because the big enter the letter is opened.

Do you have access to the httpd.conf file?
For all URLs or just category URLs?

4. If the category is called address is as follows:
/beef/

301 code with it
/beef/51-1/
I want to be redirected to address.

How will mod_rewrite know beef = 51?

Incorrect or incomplete address, error code 404 must be given in writing.

The last RewriteRule matches all 404 errors. index.php must send the 404 HTTP status code.

In large letters with Current version is open, opens in lower case letters, enter additional words in the open it is wrong to me.

I don't understand.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lavinya » Sat May 02, 2009 1:34 am

Hello. Thanks for reply. Thanks..

i updated my .htaccess file.

but the categories or recipe site, click links to open the home.

and search function not working.

Please test: k2.yemektarifleri1.com

Do you have access to the httpd.conf file?
For all URLs or just category URLs?


Yes i have access my apache vhost.conf file.
Yes for all url and category urls.

example modr function in php files:
Code: Select all
if ($SETTINGS->modr=='yes') {
       $CAT   = getTableData('categories','id',$RECIPE->cat);
       $link  = $SETTINGS->install_path.'free-recipe/'.seoUrl($CAT->catname).'/'.seoUrl($RECIPE->name).'/'.$RECIPE->id.'/index.html';
     } else {
       $link  = $SETTINGS->install_path.'?p=recipe&amp;recipe='.$RECIPE->id;
     }

Code: Select all
       if ($SETTINGS->modr=='yes') {
         header("Location: ".$SETTINGS->install_path."search-free-recipes/".urlencode($newKeys)."/all/1/index.html");
       } else {
         header("Location: ?p=search-free-recipes&keys=".urlencode($newKeys)."&cat=all");
       }
       exit;

Code: Select all
if ($SETTINGS->modr=='yes') {
     if (isset($thisParent->catname)) {
       $link = $SETTINGS->install_path.'category/'.seoUrl(cleanData($thisParent->catname)).'/'.seoUrl(cleanData($CAT->catname)).'/'.$CAT->id.'/{page}/index.html';
     } else {
       $link = $SETTINGS->install_path.'category/'.seoUrl(cleanData($CAT->catname)).'/'.$CAT->id.'/{page}/index.html';
     }


For 3 files.
k2.yemektarifleri1.com/for3files.zip

Thanks.
lavinya
 
Posts: 6
Joined: Wed Apr 29, 2009 11:55 pm

Postby richardk » Sat May 02, 2009 9:32 am

This is a big task.

Try replacing
Code: Select all
   RewriteRule ^search-free-recipes/(.*)/(.*)/(.*)/index.html$ index.php?p=search-free-recipes&keys=$1&cat=$2&next=$3 [nc]

with
Code: Select all
   RewriteRule ^search-free-recipes/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?p=search-free-recipes&keys=$1&cat=$2&next=$3 [NC,L]


Try replacing
Code: Select all
       $link  = $SETTINGS->install_path.'free-recipe/'.seoUrl($CAT->catname).'/'.seoUrl($RECIPE->name).'/'.$RECIPE->id.'/index.html';

with
Code: Select all
       $link  = $SETTINGS->install_path.seoUrl($CAT->catname).'/'.seoUrl($RECIPE->name).'-'.$RECIPE->id.'/';


Try replacing
Code: Select all
         header("Location: ".$SETTINGS->install_path."search-free-recipes/".urlencode($newKeys)."/all/1/index.html");

with
Code: Select all
         header("Location: ".$SETTINGS->install_path."search-free-recipes/".urlencode($newKeys)."/all/1/");


Try replacing
Code: Select all
       $link = $SETTINGS->install_path.'category/'.seoUrl(cleanData($thisParent->catname)).'/'.seoUrl(cleanData($CAT->catname)).'/'.$CAT->id.'/{page}/index.html';

with
Code: Select all
       $link = $SETTINGS->install_path.seoUrl(cleanData($CAT->catname)).'/'.$CAT->id.'-{page}/';
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lavinya » Sun May 03, 2009 2:34 am

Thank you for response. Sorry. Back to execute the pain, sorry.

I've updated where necessary.

RESULTS:
1. Categories, click the opening. RIGHT looks.

2. click the link to open food home. So do not open their own page. Look BUT TRUE LINKS.
EXAMPLE: k2.yemektarifleri1.com/hamur-isleri/pastane-pogacasi-458/

3. Do a search in the search box opens a homepage does not give the results.

4. Contributor links with that person to choose the recipes, but food is about to make a call. Results of the right. EXAMPLE: k2.yemektarifleri1.com/search-free-recipes/ebru/all/1/

Again this comes the "Filter Search by Category" search links are working and gives accurate results.
Search search box to see that does not work, a search turns homepage.
A recipe page links in the tag cloud recipe search page link does not work I can not try.

NOTES:
Php 3 php files for this script s url using mod_rewrite. index.php /classes /recipes.php, /control/functions.php and. htaccess file.
these 3 original file:
k2.yemektarifleri1.com/for3files.zip

want to be sure;

CATEGORIES FOR:
/category/beef/51/1/index.html
Here in
/beef/51-1/

Recipes PAGE FOR:
/free-recipe/beef/radish-explosion/3/index.html
Here in
/beef/radish-explosion-3/

SEARCH RESULTS:
(tag cloud search, in search box search, filter search, Contributor search included), the above should work in a way that the shape looks not important URLs various search functions just are working. As a matter of time would be very glad if you do too. Thank you in advance. I apologize for taking the time. goodbye to you.
lavinya
 
Posts: 6
Joined: Wed Apr 29, 2009 11:55 pm

Postby richardk » Sun May 03, 2009 9:53 am

On http://k2.yemektarifleri1.com/ the left list of categories
Code: Select all
/baliklar-1-1/
/et-yemekleri-3-1/
/kurabiyeler-5-1/
/pastalar--kekler-7-1/
/salatalar-9-1/
/tatlilar-11-1/
/zeytinyaglilar-13-1/

should be
Code: Select all
/baliklar/1-1/
/et-yemekleri/3-1/
/kurabiyeler/5-1/
/pastalar--kekler/7-1/
/salatalar/9-1/
/tatlilar/11-1/
/zeytinyaglilar/13-1/


2. click the link to open food home. So do not open their own page. Look BUT TRUE LINKS.
EXAMPLE: k2.yemektarifleri1.com/hamur-isleri/pastane-pogacasi-458/

Replace
Code: Select all
   RewriteRule ^[^/]+/[^/]+-(0-9]+)$  /$0/                          [R=301,L]
   RewriteRule ^[^/]+/[^/]+-(0-9]+)/$ /index.php?p=recipe&recipe=$3 [L]

with
Code: Select all
   RewriteRule ^[^/]+/[^/]+-([0-9]+)$  /$0/                          [R=301,L]
   RewriteRule ^[^/]+/[^/]+-([0-9]+)/$ /index.php?p=recipe&recipe=$3 [L]


3. Do a search in the search box opens a homepage does not give the results.

Replace
Code: Select all
    <!-- Search Form -->
    <form method="post" action="index.html">

with
Code: Select all
    <!-- Search Form -->
    <form method="post" action="./">
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lavinya » Sun May 03, 2009 10:26 pm

Greetings.
Thank you for responding. Sorry you had so much head pain. Sorry.

Yes is the last way. We have:
1. CATEGORY LINKS running. CORRECT URLS look. (Only /corbalar/2-1/ this address /corbalar/2-1 in this way is entered automatically to / does not sign and only /corbalar/ as it is called /corbalar/2-1/ this is not directed to address.)

2. Link to SEARCH is working and the problem does not appear. (But only in the tag cloud page recipe search system can not try because the recipe does not open the page. All other search system works. Thank you.:))

3. ONLY recipe does not turn the pages.
This page gives a 404 error code. example url: k2.yemektarifleri1.com/corbalar/acili-domates-corbasi-422/

(But you look like URLs, and address right to the end / marker in this system which is automatic, even as I want.)

NOTE: This code I
RewriteRule ^[^/]+/[^/]+-([0-9]+)/$ /index.php?p=recipe&recipe=$3 [L]
I tried to change the following code was working. But I do not even have the code. But it works as follows:
RewriteRule ^(.*)/(.*)-([0-9]+)/$ /index.php?p=recipe&recipe=$3 [L]

NOTE:
Some non-404 error code instead of the home address is 200 the answer is open. Examples:
k2.yemektarifleri1.com/dsfgsdgsgd ,
k2.yemektarifleri1.com/ddsfsd/dsfdsf/ ,
k2.yemektarifleri1.com/baliklar/1-1/sdafasfasfafsasf ,
k2.yemektarifleri1.com/hamur-isleri/patlicanli-ve-peynirli-milfoy-683/dsfdsgsdgsdgsdsgd ,
k2.yemektarifleri1.com/richardk.jpg ,
k2.yemektarifleri1.com/richardk.png ,
and similar....
:(

Again, thank you. Good day, I wish you good work. See you soon.
lavinya
 
Posts: 6
Joined: Wed Apr 29, 2009 11:55 pm

Postby richardk » Mon May 04, 2009 12:45 pm

1. CATEGORY LINKS running. CORRECT URLS look. (Only /corbalar/2-1/ this address /corbalar/2-1 in this way is entered automatically to / does not sign and only /corbalar/ as it is called /corbalar/2-1/ this is not directed to address.)

Do you have access to the http.conf file? If you do not you will need a PHP script (with mod_rewrite) to do that.

3. ONLY recipe does not turn the pages.
This page gives a 404 error code. example url: k2.yemektarifleri1.com/corbalar/acili-domates-corbasi-422/

Try
Code: Select all
   RewriteRule ^[^/]+/[^/]+-([0-9]+)$  /$0/                          [R=301,L]
   RewriteRule ^[^/]+/[^/]+-([0-9]+)/$ /index.php?p=recipe&recipe=$1 [L]


NOTE:
Some non-404 error code instead of the home address is 200 the answer is open.

Try removing
Code: Select all
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ /index.php [QSA,L]

The script needs changing so that it outputs a 404 error for some of those URLs.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lavinya » Mon May 04, 2009 10:12 pm

Hi richardk.
Thanks.
Many issues have been resolved.

Do you have access to the http.conf file?


Yes, i have access to my http.conf file.

Again, thank you...
lavinya
 
Posts: 6
Joined: Wed Apr 29, 2009 11:55 pm

Postby richardk » Tue May 05, 2009 11:41 am

Try adding
Code: Select all
RewriteMap lowercase int:tolower

to your httpd.conf file.

Then adding
Code: Select all
   RewriteCond %{REQUEST_URI} [A-Z]
   RewriteRule ^([^/]+/[^/]+-[0-9]+)/?$  /${lowercase:$1|failed}/    [R=301,L]

before
Code: Select all
   RewriteRule ^[^/]+/[^/]+-([0-9]+)$  /$0/                          [R=301,L]


The replacing
Code: Select all
   RewriteRule ^.+/([0-9]+)-([0-9]+)/?$   /index.php?p=category&cat=$1&next=$2  [L]

with
Code: Select all
   RewriteCond %{REQUEST_URI} [A-Z]
   RewriteRule ^(.+/[0-9]+-[0-9]+)/?$    /${lowercase:$1|failed}/              [L]

   RewriteRule ^.+/[0-9]+-[0-9]+$        /$0/                                  [L]
   RewriteRule ^.+/([0-9]+)-([0-9]+)/$   /index.php?p=category&cat=$1&next=$2  [L]


The replacing
Code: Select all
   RewriteRule ^(.*)$ /index.php [QSA,L]

with
Code: Select all
   RewriteRule ^(([^/]+)(/(.*))?)?$ /index.php?mr_dir=$2&mr_rest=$4 [QSA,L]


Then adding the following to the beginning of index.php
Code: Select all
if(getenv('REDIRECT_STATUS') !== false && isset($_GET['mr_dir']) &&
  !empty($_GET['mr_dir']) && isset($_GET['mr_rest']) && empty($_GET['mr_rest']))
{
  $mr_categories = array(
    'beef' => '51',
    'chicken' => '123'
    );
  if(isset($mr_categories[strtolower($_GET['mr_dir'])]))
  {
    header('Location: http://' . getenv('HTTP_HOST') . '/' . strtolower($_GET['mr_dir'])
      . '/' . $mr_categories[strtolower($_GET['mr_dir'])] . '-1/', true, 301);
    exit();
  }
  unset($_GET['mr_dir'], $_GET['mr_rest'], $mr_categories);
}


You will have to add the other categories to
Code: Select all
  $mr_categories = array(
    'beef' => '51',
    'chicken' => '123'
    );
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 25 guests

cron