Forum

URL rewriting for LemonStand

David Oliver
3 July 2012, 00:05
Hi,

I've got so far with converting the basics of LemonStand's RewriteRules, but would appreciate any help or pointers from anyone with the remaining lines.

.htaccess rewrites:

#
# Do not allow executing any PHP scripts
#

RewriteRule ^(.*).php$ index.php [L]

#
# The following section automatically adds a trailing slash to all URLs
#

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
RewriteCond %{REQUEST_METHOD} !^HEAD$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule (.*)([^/])$ %{REQUEST_URI}/ [R=301,L]

#
# Product files downloading URL
#

RewriteRule (^download_product_file/.*) index.php?q=/$1 [L,QSA]

#
# Administration Area file downloading URL
#

RewriteRule ls_backend/files/get/(.*) index.php?q=/backend_file_get/$1 [L]

#
# All other requests
#

RewriteCond %{REQUEST_URI} !(\.(ico|js|jpg|jpeg|gif|css|png|swf|txt|xml|xls)$) [NC]
RewriteCond %{REQUEST_URI} !(phproad/thirdpart/.*)
RewriteRule ^(.*)$ index.php?q=/$1 [L,QSA]


What I've got so far:

UrlToolkit {
ToolkitID = lemonstand

# Disallow execution of other PHP scripts
Match ^/(.*).php$ Rewrite /index.php

# TODO Add a trailing slash to all URLs


# Product files downloading URL
Match (^/download_product_file/.*) Rewrite /index.php?q=$1

# Administration Area file downloading URL
Match ^/ls_backend/files/get/(.*) Rewrite /index.php?q=/backend_file_get/$1

# TODO All other requests

}
David Oliver
3 July 2012, 11:12
I now have the following, which isn't complete or an exact match, but it seems to be at least partially working. To be further developed. :-)

UrlToolkit {
ToolkitID = lemonstand

Match ^/config/ Deny

# Disallow execution of other PHP scripts
Match ^/(.*).php$ Rewrite /index.php

# TODO Add a trailing slash to all URLs


# Product files downloading URL
Match (^/download_product_file/.*) Rewrite /index.php?q=$1

# Administration Area file downloading URL
Match ^/ls_backend/files/get/(.*) Rewrite /index.php?q=/backend_file_get/$1

# All other requests
RequestURI isfile Exit
Match ^/phproad/thirdpart/.* Exit
Match ^/(.*)$ Rewrite /index.php?q=$1
}


I have another issue which I think isn't related to URL rewriting, which I'll post on separately.
Hugo Leisink
3 July 2012, 19:59
RewriteRule ^(.*).php$ index.php [L]
- Match ^/.*\.php$ Rewrite /index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
- RequestURI exists Return

RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
- Match ^/(\.[a-zA-Z0-9]{1,5})?$ Return

RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
RewriteCond %{REQUEST_METHOD} !^HEAD$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule (.*)([^/])$ %{REQUEST_URI}/ [R=301,L]
- No UrlToolkit equivalents

RewriteRule (^download_product_file/.*) index.php?q=/$1 [L,QSA]
- Match ^/(download_product_file/.*)\?(.*) Rewrite /index.php?q=/$1&$2
- Match ^/(download_product_file/.*) Rewrite /index.php?q=/$1

RewriteRule ls_backend/files/get/(.*) index.php?q=/backend_file_get/$1 [L]
- Match ls_backend/files/get/(.*) Rewrite /index.php?q=/backend_file_get/$1

RewriteCond %{REQUEST_URI} !(\.(ico|js|jpg|jpeg|gif|css|png|swf|txt|xml|xls)$) [NC]
- Match \.(ico|js|jpg|jpeg|gif|css|png|swf|txt|xml|xls)$ Return

RewriteCond %{REQUEST_URI} !(phproad/thirdpart/.*)
- Match phproad/thirdpart/.* Return

RewriteRule ^(.*)$ index.php?q=/$1 [L,QSA]
- Match ^/(.*)\?(.*)$ Rewrite /index.php?q=/$1&$2
- Match ^/(.*)$ Rewrite /index.php?q=/$1


No offence, but LemonStand has a serious design issue. No CMS / framework should ever require a weird and complex URL rewrite like this.
David Oliver
4 July 2012, 13:11
Thanks Hugo. Your rules work better (but not entirely) than mine for the actual pages, but don't allow for loading of the CSS file (and I can't see why).

Yes, this is very annoying and I'm thinking of giving up with Lemonstand or setting up another VPS for Apache. :-(

Do you have any experience with or recommendations for eCommerce applications? I'm currently on the lookout for a project, which is why I was trying LemonStand.

Magento seems very featureful but I used to find it maintenance heavy.

PrestaShop also seems featureful, but apparently the view layer is a mess and I don't want to have to fight it to do my own theme should that be necessary.
Hugo Leisink
4 July 2012, 14:25
I have no experience with eCommerce applications. All I have done with eCommerce, I wrote myself
David Oliver
6 July 2012, 20:46
I now have Magento installed and working via Hiawatha.

The URL toolkit isn't complete yet, but I'll post it when it is and I've done more testing.
This topic has been closed.