1

I'm managing an e-commerce site for a customer that was built using JShop on Apache. For SEO reasons links are like:

http://www.domain.com/shop/section/3151/1/flowers
http://www.domain.com/shop/product/35465/blueflower

which get mapped to:

http://www.domain.com/shop/section.php/3151/1/flowers
http://www.domain.com/shop/product.php/35465/blueflower

which give the same pages as:

http://www.domain.com/shop/section.php?xSec=3151&xPage=1
http://www.domain.com/shop/product.php?xSec=35465

Somehow this is achieved without mod_rewrite (I have confirmed this by disabling mod_rewrite and commenting out all rewrite rules in all conf and .htaccess files).

Note: The files section.php and product.php exist, but section and product do not, nor are there symlinks.

The problem is that on the production server this behavior stopped happening. On my dev server it still works. I was able to get the production server working correctly again by using mod_rewrite since this is the only way I know how to do this. However I really need to know what changed on the production server in the first place so I can properly understand the problem (to avoid other unforeseen consequences). I have restarted Apache and undone all changes I was making on the production server at the time the URLs became broken. They are still broken (without my new rewrite rules).

What methods other than mod_rewrite can be used to remove .php extensions from URLs?

3 Answers 3

5

Content Negotiation can do this. Enable MultiViews for shop folder:

<Directory "/path/to/shop">
    Options FollowSymLinks +MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

When the server receives a request /shop/section/3151/1/flowers (section does not exist), it will look up for section.* in shop folder, sort based on the media types and content-encodings send by the browser and choose the best match.

1
  • Wow, thanks, this was exactly the reason. I never knew MultiViews worked this way.
    – rwired
    Sep 13, 2011 at 11:41
2

Mod_alias, perhaps. Something like:

AliasMatch ^/shop/section/(.*)/(.*)/(.*)$ /shop/section.php?xSec=$1&xPage=$3
AliasMatch ^/shop/product/(.*)/(.*)$ /shop/product.php?xSec=$1
0

It could be using PATH_INFO - more details here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .