Apache Lounge



Forum Index Downloads Search Register Log in  RSS Apache Lounge

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.

htaccess mod_rewrite - friendly URLs

Post new topic   Reply to topic    Apache Forum Index -> Apache

View previous topic :: View next topic  
Author Message

Joined: 18 Aug 2017
Posts: 2
Location: United Kingdom

PostPosted: Fri 18 Aug '17 21:19    Post subject: htaccess mod_rewrite - friendly URLs Reply with quote

Evening guys,

I have been attempting to get mod rewrite working for product id's but I am having no luck at all. I have tried searching Stack Overflow but there are no clear explanations and I have read the apache documentation.

I have an ecommerce store


I want to change these URLs




I wish to keep /ecommerce/ in the URL Smile

This is my current htaccess rewrite rules:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

RewriteRule ^ecommerce/(.*)$ ecommerce/product?id=$1 [L]

This file has been added to www.peakwebdesigns.co.uk

Other details:

Running Apache 2.4 on my GoDaddy server.
Windows 10 on my PC

Would appreciate any help.

Back to top

Joined: 16 Jun 2015
Posts: 11
Location: Spain

PostPosted: Mon 21 Aug '17 0:30    Post subject: Reply with quote

Hi Stan,

Try with this:

RewriteRule ^ecommerce/(.*)$ /ecommerce/product?id=$1 [L]

Regards Smile
Back to top

Joined: 18 Aug 2017
Posts: 2
Location: United Kingdom

PostPosted: Fri 25 Aug '17 22:18    Post subject: Reply with quote

Thank you for your reply yosoyminero.

I have tried with the code you provided but it still doesnt work.

I am typing http://www.peakwebdesigns.co.uk/ecommerce/2

but I get a 404 page.


I used the following to get this working:
RewriteRule ^ecommerce/product/(.*)$ ./ecommerce/product?id=$1 [L,NC]

RewriteRule ^ecommerce/category/(.*)$ ./ecommerce/category_page?category_name=$1 [L,NC]
Back to top

Post new topic   Reply to topic    Apache Forum Index -> Apache
Page 1 of 1