Jump to content
Sign in to follow this  
Romey-Rome

YASU

Recommended Posts

I have the Shop in the root and I runs.

 

Options +FollowSymLinks

RewriteEngine on

RewriteRule statistik - [L]

RewriteRule admin - [L]

 

RewriteCond %{REQUEST_URI} !-d

RewriteCond %{REQUEST_URI} !^/$

RewriteRule !\.(gif|php|css|jpg|jpeg|txt|htm)$ /rewrite.php

Share this post


Link to post
Share on other sites

Retriver-

Thanks for the code? How did you modify rewrite.php to remove any references to 'catalog'? Did you modify rewrite.php?

 

Burke

Share this post


Link to post
Share on other sites

I GOT IT WORKING! Still doing a thorough test, but everything appears to be in order.

 

I have OsCommerce installed in the root, and I finally tweaked the rewrite.php to eliminate all references to 'catalog', and it worked!

 

I can't wait to see how this impacts the rankings. I have been holding solid, ranking just behind my competitors that have product names, etc in the URL. So I am betting this will help.

 

If anyone would like to see my code for a root installation, let me know and I can either PM you or if it is okay, I could post it here. Just let me know.

 

Burke

Share this post


Link to post
Share on other sites
is it possible to change it into domain.com/computer-cpu-cooler?
Sure. You would lose the ability to include dashes in the product, category, and manufacturer names though. You can just add str_replace calls in rewrite.php and the tep_href_link function.

 

Hth,

Matt

Matt,

Exactly how would this code look? I would like to swap a couple of characters out like a comma.

 

Thanks!

 

Burke

Share this post


Link to post
Share on other sites
Exactly how would this code look?

To change + signs into dashes, change the following line from html_output.php

          $link .= preg_replace('/%2F/', '%20', implode('/', $cPath_list));

to

          $link .= preg_replace(array('/%2F/', '/+/'), array('%20', '-'), implode('/', $cPath_list));

In rewrite.php, change

    $piece = urldecode(preg_replace(array('/[+]/', '/%20/'), array(' ', '%2F'), $piece_encoded));

to

    $piece = urldecode(preg_replace(array('/-/', '/%20/'), array(' ', '%2F'), $piece_encoded));

Or more generally,

    $piece = urldecode(preg_replace(array('/[+]/', '/%20/'), array('_', '%2F'), $piece_encoded));

and change the SQL queries to use LIKE rather than =. For example,

    $category_query = tep_db_query("select cd.categories_id from categories_description cd, categories c where cd.categories_id=c.categories_id and cd.categories_name='" . tep_db_input($piece) . "' and c.parent_id='" . (int)$current_category_id . "'");

would become

    $category_query = tep_db_query("select cd.categories_id from categories_description cd, categories c where cd.categories_id=c.categories_id and cd.categories_name like '" . tep_db_input($piece) . "' and c.parent_id='" . (int)$current_category_id . "'");

as the _ will match any character when used this way.

 

Hth,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

Matt, I tried the above and get this nasty error, don't know what to do to get the code correct. Thanks for taking the time to post a solution but it isn't working on my end. Here is the error.

Compilation failed: nothing to repeat at offset 0

It has something to do with html_output

 

Mair :(

Share this post


Link to post
Share on other sites

          $link .= preg_replace(array('/%2F/', '/+/'), array('%20', '-'), implode('/', $cPath_list));

should be

          $link .= preg_replace(array('/%2F/', '/[+]/'), array('%20', '-'), implode('/', $cPath_list));

Hth,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

I try to find a solution for the same problem that Ludo:

 

Hello,

 

i don't understand how to make the modifications to change '+' --> '-'

 

I would like to make modification to change all ' ?, ?, ?, ? ....' --> 'e, e, u, a ....' and all ",' ... to --> space

 

Thanks

 

Ludo

 

:huh:

 

somebody have a id?e ?

Share this post


Link to post
Share on other sites

I'm looking for some help here. I have my oscommerce installation in the root, not in catalog, and i've managed to get it working fine with the changed .htaccess script:

<IfModule mod_setenvif.c>
 <IfDefine SSL>
   SetEnvIf User-Agent ".*MSIE.*" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
 </IfDefine>
</IfModule>

   Options +FollowSymLinks
   RewriteEngine   on
   RewriteRule     feeds                      - [L]
   RewriteRule     seo                        - [L]
   RewriteRule     admin                      - [L]
   RewriteCond     %{REQUEST_URI}             !-d
   RewriteCond     %{REQUEST_URI}             !^/$
   RewriteRule     !\.(gif|php|css|jpg|JPG|GIF|html|htm)$      /rewrite.php

 

 

 

BUT, my problem occurs when i try to password protect the admin directory. Strange thing it does is when i go to "domain.com/admin/" it will redirect me to "domain.com/advanced_search_result.php?keywords=admin". I cannot access the admin when I have password protection enabled.

 

The .htaccess file automatically generated by my host when i password protect the admin directory is:

AuthType Basic

AuthName "Restricted Area"

AuthUserFile "/home/moya/.htpasswds/admin/passwd"


require valid-user

 

What can I do to password protect the admin AND keep my oscommerce installation in the root?

 

I would really appreciate the help!

Share this post


Link to post
Share on other sites

HHHmmmm...

 

I do have osC in a directory other than root. But took a look at my .htaccess files.

 

My .htaccess for the catalog directory has the admin commented out, as I was having trouble getting in. I don't remember if it was the same issue as you, but may want to give that a try.

 

My admin directory .htaccess which looks just like yours, is in the admin directory, not in the root or catalog .htaccess. Just FYI.

 

Hope this helps.

 

 

I'm looking for some help here.  I have my oscommerce installation in the root, not in catalog, and i've managed to get it working fine with the changed .htaccess script:

<IfModule mod_setenvif.c>
?<IfDefine SSL>
? ?SetEnvIf User-Agent ".*MSIE.*" \
? ? ? ? ? ? nokeepalive ssl-unclean-shutdown \
? ? ? ? ? ? downgrade-1.0 force-response-1.0
?</IfDefine>
</IfModule>

? ?Options +FollowSymLinks
? ?RewriteEngine ? on
? ?RewriteRule ? ? feeds ? ? ? ? ? ? ? ? ? ? ?- [L]
? ?RewriteRule ? ? seo ? ? ? ? ? ? ? ? ? ? ? ?- [L]
? ?RewriteRule ? ? admin ? ? ? ? ? ? ? ? ? ? ?- [L]
? ?RewriteCond ? ? %{REQUEST_URI} ? ? ? ? ? ? !-d
? ?RewriteCond ? ? %{REQUEST_URI} ? ? ? ? ? ? !^/$
? ?RewriteRule ? ? !\.(gif|php|css|jpg|JPG|GIF|html|htm)$ ? ? ?/rewrite.php

BUT, my problem occurs when i try to password protect the admin directory.  Strange thing it does is when i go to "domain.com/admin/" it will redirect me to "domain.com/advanced_search_result.php?keywords=admin".  I cannot access the admin when I have password protection enabled.

 

The .htaccess file automatically generated by my host when i password protect the admin directory is:

AuthType Basic

AuthName "Restricted Area"

AuthUserFile "/home/moya/.htpasswds/admin/passwd"
require valid-user

 

What can I do to password protect the admin AND keep my oscommerce installation in the root?

 

I would really appreciate the help!


Steve K AKA - Knipper -

Share this post


Link to post
Share on other sites
HHHmmmm...

 

I do have osC in a directory other than root. But took a look at my .htaccess files.

 

My .htaccess for the catalog directory has the admin commented out, as I was having trouble getting in.  I don't remember if it was the same issue as you, but may want to give that a try.

 

My admin directory .htaccess which looks just like yours, is in the admin directory, not in the root or catalog .htaccess.  Just FYI.

 

Hope this helps.

 

Thanks, but I too have other sites with oscommerce in a directory other than root (namely /catalog) and password protecting the admin works fine on those sites... it's only the ones with oscommerce installed in the root that give me problems when password protecting the admin. Thanks for the advice, though.

Share this post


Link to post
Share on other sites
BUT, my problem occurs when i try to password protect the admin directory.? Strange thing it does is when i go to "domain.com/admin/" it will redirect me to "domain.com/advanced_search_result.php?keywords=admin".? I cannot access the admin when I have password protection enabled.

Hi hobbyhen,

 

I had the same thing on a clients server, it would re-direct when trying to access /admin/ - strangely the code worked perfectly on my server!

 

Anyway - we got around it by adding the rule below into the htaccess file, it stops the rewrite rule when the site is accessed via SSL - so https://www.theserver.com/admin/ would still enter the admin. Doesn't solve the issue itself but it a workaround if you have SSL.

 

RewriteCond %{SERVER_PORT} !^443$

Edited by RicherDesigns

Share this post


Link to post
Share on other sites

OK...

 

New Question. This mod is working great. But I'd like to tray and take it one step farther. One thing I noticed is when using the Dropdown boxes is that the path goes back to the osC original URL like...

 

http://www.mydomain/catalog/index.php?cPath=10

 

I'd like the dropdowns to work like the other links, giving a friendly URL like...

 

http://www.mydomain/catalog/DVD_Movies/Action

 

One odd thing I noticed is from the "Item Page" is the Manufacturers info box on the right, which has more info about the vendor and/or a link to their home page. The odd part is if you click the link from there, you DO get the Friendly URL. But using the dropdown for the same manufacturer you get the standard dynamic url like shown above.

 

Anyone know what would need to be modified to make the dropdowns work like the rest of the links when using this mod?

 

Thanks in advance!


Steve K AKA - Knipper -

Share this post


Link to post
Share on other sites
Hello,

 

i don't understand how to make the modifications to change '+' --> '-'

 

I would like to make modification to change all ' ?, ?, ?, ? ....' --> 'e, e, u, a ....' and all ",' ... to --> space

 

Thanks

 

Ludo

 

 

 

Hello,

 

I installed Yasu and that works, but I look for the means to eliminate the characters and the accents in the links.

 

Thank you for your assistant.

Share this post


Link to post
Share on other sites
So I see a lot of people trying to change the '+' to '-'.  What is the advantage to doing this?

 

I do not know!

But I I try to eliminate the characters and the accents in the links.

And I do not find solution.

 

Please help me!!

Share this post


Link to post
Share on other sites
I do not know!

But I I try to eliminate the characters and the accents in the links.

And I do not find solution.

 

Please help me!!

 

 

From what I remember there used to be a debate about which character (-) or (_) was best to use when making SEF links. Supposedly (-) won out as being better to use. It also looks a bit better than (+) IMHO.

 

 

--

Actually my big problem is " " and & in names, is there a way to fix these so they don't show up as %93 %94 in the URL?

 

Thanks for this mod, this is the first one I found that used category names and item names in the link, exactly what I wanted :)

 

Cheers!

Share this post


Link to post
Share on other sites

I the Yasu contribution on a test subdomain that has a catalog folder. http://store1.domain.com/catalog/Inkwells and the mod worked great up until I try to checkout. I get an error message - Redirect Limit for this URL exceeded. Unable to open requested page. This may be caused by cookies that are blocked.

I do not have my cookies blocked and also tried it in IE - can't find server (cookies not blocked) Admin settings: force cookie use to true / Prevent spider sessions true.

 

Any suggestions on what the problem would be?

 

I also would like to use this with another store without the catalog directory.

http://store2.domain.com/

 

I read the post but can't figure out if anyone has this working and if so what did work. If anyone has this working can you please post what you did?

 

Thanks

 

 

 

 

From what I remember there used to be a debate about which character (-) or (_) was best to use when making SEF links. Supposedly (-) won out as being better to use. It also looks a bit better than (+) IMHO.

--

Actually my big problem is " " and & in names, is there a way to fix these so they don't show up as %93 %94 in the URL?

 

Thanks for this mod, this is the first one I found that used category names and item names in the link, exactly what I wanted :)

 

Cheers!

Share this post


Link to post
Share on other sites

Hi - to get Yasu working on top level domain (i.e. without /catalog directory), use this on your .htaccess:

 

RewriteEngine on

RewriteBase /

RewriteRule admin - [L]

RewriteRule ^$ /index.php [R=301,L]

RewriteRule ^/$ /index.php [R=301,L]

RewriteCond %{REQUEST_URI} !-d

RewriteCond %{REQUEST_URI} !^/$

 

 

Hope that helps, but I also have a question of my own. With YASU installed, I cannot get gzip to work at all. My site is incredibly slow, but indexed well in the search engines. I would like the best of both worlds, with SEF urls working, but also a quick site with gzip working. Anybody have any workarounds for this? Am I being increibly dumb and is this fairly simple, or if it hasn't been done yet anybody have a clue how it could be done? At the minute I have left the rewrite engine on, but removed the bit in includes/functions/html_output which makes the links search engine friendly. This makes the links the search engines already have still work (i.e. www.niknakgroup.com/Gold+Pendants), but wont let them find anymore links of this style.....ok for the minute as it still lets me use gzip, but not ideal....anybody help?


Please note - if I have suggested a contrib above, it doesnt mean it will work! Most of the contribs are not ones I've used, but may be useful for your particular problem....

Have you tried a refined search? Chances are your problem has already been dealt with elsewhere on the forums.....

if (stumped == true) {

return(square_one($start_over)

} else {

$random_query = tep_fetch_answer($forum_query)

}

Share this post


Link to post
Share on other sites
I have not yet tried this, but there is a new contribution called "PName and CName" and it puts the product name and the category name into the URL without .htaccess and without apache rewrite rules.

 

http://www.oscommerce.com/community/contributions,2747

 

I suggest someone try this because it may speed up the site???

 

 

Using that now... works pretty darn well. No need to worry about " " or weird characters in the product names either. Speeds it up because your site isn't being processed for link changes by the server with every page (to put it simply). It's really a matter of taste though, both seem to work pretty well.

Share this post


Link to post
Share on other sites
...

 

http://www.oscommerce.com/community/contributions,2747

 

I suggest someone try this because it may speed up the site???

 

 

This contrib is really nice, but where I can change this

 

-> URL with product and category name

 

to this

 

-> URL with product name

 

I could not find it in the admin menu ...?


Cheers

 

+++ http://www.muehlkoppe.de +++

Share this post


Link to post
Share on other sites
...

 

http://www.oscommerce.com/community/contributions,2747

 

I suggest someone try this because it may speed up the site???

 

Not sure if you want to try this. I read on the web that google and other search engines do not like URL's containing '?' This contribution may prevent your pages being indexed. Please verify.

 

On my website, YASU is installed and it works fine. Only changes I made is to redirect the page to index.php instead of advanced_search.php See code below modified in rewrite.php

 

        } else {
         reset($list);
         //added 03/29/05 start change
         //tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . implode('+', $list)));
         tep_redirect(tep_href_link(FILENAME_DEFAULT));
         //added 03/29/05 end change
       }

 

My category names are like "Baby & Kids", "Food/Grocery"

Can someone tell me what I need to fix to avoid getting %26 instead of '&', %20 instead of '/' in the URL?

Thanks.


-- Reality is an illusion caused due to lack of alcohol.

-- We are never too old to learn something new.

Share this post


Link to post
Share on other sites

I found a bug. When clicking on a product in the new products box the links are:

 

http://www.domain.com/catalog/Speed

 

instead of

 

http://www.domain.com/catalog/DVD+Movies/Action/Speed

 

How do i fix this problem?

 

-Ryan

 

PS: Here is some code that may help, but i don't know what to do with it

 

			//ADD CATEGORY NAME MODIFICATION - BB 2005-11-08
		//If cPath isn't in the URL, category names aren't added to the URL
		//This fixes that
		if (strpos($url, 'cPath') === false) {
		  $cat_array = array();
		  $cat_query = tep_db_query("SELECT cd.categories_name as name, c.parent_id FROM categories c LEFT JOIN categories_description cd ON (c.categories_id = cd.categories_id) LEFT JOIN products_to_categories p2c ON (p2c.categories_id = c.categories_id) WHERE p2c.products_id = '" . (int)$url_array[$i] . "' AND p2c.categories_id = c.categories_id AND cd.language_id = '" . (int)$languages_id . "'");
		  $cat_val = tep_db_fetch_array($cat_query);

		  $cat_array[] = $cat_val['name'];

		  //If this category has a parent, get the name
		  if (is_numeric($cat_val['parent_id']) && $cat_val['parent_id'] != '0') {
			$parent_id = $cat_val['parent_id'];
			while ($parent_id != '0') {
			  $cat_query = tep_db_query("SELECT cd.categories_name as name, c.parent_id FROM categories c LEFT JOIN categories_description cd ON (c.categories_id = cd.categories_id) WHERE cd.categories_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$languages_id . "'");
			  $cat_val = tep_db_fetch_array($cat_query);

			  $cat_array[] = $cat_val['name'];
			  $parent_id = $cat_val['parent_id'];
			}
		  }

		  //Reverse array order
		  $cat_array = array_reverse($cat_array);

		  for ($x = 0; $x <= sizeof($cat_array); $x++) {
			$url_parts['path'] .= '/' . $this->prepare_url($cat_array[$x]);
		  }
		}
		//END MODIFICATION - BB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×