Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 Extensionless URL's & Rewrites
Author « Topic »  

1818charlie
ECT Moderator

United Kingdom
1180 Posts

Posted - 06/06/2021 :  04:20:26  
An experimental site I am working on is not an ecommerce site but will be using ECT.

Having gone through the search engine friendly URLs setup instructions,
https://www.ecommercetemplates.com/seo/search-engine-friendly-urls-php.asp ,
these seem to be working fine & are returning 200 status codes. All looking good!

The issue I have at the moment is that using either the $extension=""; or
$extension="/"; so as to use extensionless URLs for other store pages doesn't
produce the expected result, all URLs still end in php.

I have cleared the Litespeed cache & the browser doesn't keep history, cookies etc.

Any ideas?

Server PHP version 7.4.16
ECT Version 7.3.3
Server is Litespeed


Steve
Bolton Lancashire

Edited by - 1818charlie on 09/28/2021 08:09:24

Vince
Administrator

42474 Posts

Posted - 06/06/2021 :  09:11:18  
quote:
doesn't produce the expected result, all URLs still end in php.
How are you testing this, Steve? For instance, if you have the extension as "/" you still have to add entries to the .htaccess file so that say "cart/" maps to "cart.php". But once on the first "cart/" page then clicking the "checkout" button should take you to the customer details on "cart/". Are you saying that's not the case?

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

1818charlie
ECT Moderator

United Kingdom
1180 Posts

Posted - 06/06/2021 :  12:59:41  
Hi Vince

This is the htaccess file content

AddDefaultCharset UTF-8

<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header set Connection keep-alive
</IfModule>

##X Robots Header
Header set X-Robots-Tag "noindex, nofollow"

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
# REDIRECT www
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
# REDIRECT index.php (THIS DOES NOT EFFECT SUBFOLDERS !!)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ https://mysite.com/$1 [R=301,L]
# ECT URL Rewrites
RewriteRule ^category/([^/.]*)/?$ /categories.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^pages/([^/.]*)/?$ /products.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^manufacturer/?$ /categories.php?man=all [QSA,nc,L,B]
RewriteRule ^manufacturer/([^/.]*)/?$ /products.php?man=$1 [QSA,nc,L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) proddetail.php?prod=$1 [QSA,nc,L,B]
RewriteRule ^cart/$ cart.php [NC,L]
</IfModule>

with either $extension="/"; or $extension=""; in the includes file.

Anything there that shouldn't be or something missing?



Steve
Bolton Lancashire

Edited by - 1818charlie on 06/06/2021 13:00:35

Vince
Administrator

42474 Posts

Posted - 06/06/2021 :  13:58:35  
Hi Steve
I see the problem. This rule for the product detail page is like a "catch all" rule and will match anything that hasn't been previously matched and isn't a physical file or directory...

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) proddetail.php?prod=$1 [QSA,nc,L,B]

So you have to have the cart/ rule...
RewriteRule ^cart/$ cart.php [NC,L]
...BEFORE it, otherwise "cart/" is just going to be fed to the product detail page.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

1818charlie
ECT Moderator

United Kingdom
1180 Posts

Posted - 06/08/2021 :  02:08:30  
Hi Vince

Having moved the line RewriteRule ^cart/$ cart.php [NC,L] that now displays a URL of domain.com/cart/. I'll check over that all works as expected

Thank you

Steve
Bolton Lancashire

1818charlie
ECT Moderator

United Kingdom
1180 Posts

Posted - 09/28/2021 :  07:52:25  
I could do with seeing if my understanding is correct & apologies for the long winded post.

Q1 - Regarding the two URL rewrite lines highlighted in red below, is my understanding correct in thinking that if the typed URL in the browser is domain.com/products.php, then the URL shown in the browser address bar should be domain.com/pages/ & the same with the categories.php showing /category/? All I am getting is domain.com/products.php, it never shows domain.com/pages/ but when actually typing in domain.com/pages/ or domain.com/category to the browser address field I see the products & category pages correctly & the web address bar shows domain.com/pages/ or /category/.

Why is the rewrite not occuring? Or is this related to Q2 below?

From the following article at the foot of the page it states The LiteSpeed rewrite engine will stop processing rewrite rules after encountering an [L] flag to avoid looping while Apache mod_rewrite will stop processing rewrite rules for the current iteration only. This behavior is similar to that of the [END] flag in Apache mod_rewrite.
https://www.litespeedtech.com/docs/webserver/config/rewrite

Q2 - So the [L] flag appears in the following directives but I'm guessing it shouldn't or should it be replaced by something else that's required on a LiteSpeed server?

NOTE - The LightSpeed cache has been flushed & the browser does not cache anything

HTACCESS ENTRIES

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]
# REDIRECT www
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]
# REDIRECT index.php (THIS DOES NOT EFFECT SUBFOLDERS !!)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ https://domain.com/$1 [R=301]
# ECT URL Rewrites
RewriteRule ^category/([^/.]*)/?$ /categories.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^pages/([^/.]*)/?$ /products.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^manufacturer/?$ /categories.php?man=all [QSA,nc,L,B]
RewriteRule ^manufacturer/([^/.]*)/?$ /products.php?man=$1 [QSA,nc,L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) proddetail.php?prod=$1 [QSA,nc,L,B]
</IfModule>

INCLUDES FILE ENTRIES

$seodetailurls=TRUE;
$seocategoryurls=TRUE;
$detlinkspacechar="-";
$seocaturlpattern="/category/%s";
$seoprodurlpattern="/pages/%s";

Steve
Bolton Lancashire

Edited by - 1818charlie on 09/28/2021 10:25:59
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000