Jump to content

Recommended Posts

Hi all

 

I'm trying to get my .htaccess file to internally redirect from, say:

 

mysite.com/salon/the-name-of-someone/treatments

 

to...

 

mysite.com/salon/treatments.php?salon=the-name-of-someone

 

I'm trying the following, but it won't work:

RewriteRule salon/([a-z0-9\-]+)/treatments$ /salon-stub/index.php?salon=$1 [L]

think the following rule which redirects mysite.com/salon/the-name-of-someone to mysite.com/salon/index.php?salon=the-name-of-someone (successfully), might be causing the problem:

RewriteRule salon/([a-z0-9\-]+)$ /salon-stub/index.php?salon=$1 [L]
Link to comment
https://forums.phpfreaks.com/topic/286854-rewrite-rule-doesnt-work/
Share on other sites

Thanks for the help so far, requinix! Here's the complete .htaccess:

RewriteEngine On
# If it's not a directory...
RewriteCond %{REQUEST_FILENAME} !-d
# ...and it has a trailing slash then redirect to URL without slash
RewriteRule ^(.+)/$ /$1 [L,R=301]

# Rewrite rules for profiles and username mapping
RewriteRule ^([a-z0-9\-]+)$ /user/index.php?prof=$1 [L]
RewriteRule ^([a-z0-9\-]+)/treatments$ /user/treatments.php?prof=$1 [L]
RewriteRule ^([a-z0-9\-]+)/reviews$ /user/reviews.php?prof=$1 [L]
RewriteRule ^([a-z0-9\-]+)/photos$ /user/photos.php?prof=$1 [L]

# Rewrite rules for salons
RewriteRule salon/([a-z0-9\-]+)$ /salon-stub/index.php?salon=$1 [L]
RewriteRule salon/([a-z0-9\-]+)/treatments$ /salon-stub/treatments.php?salon=$1 [L]

The last two lines are the ones I'm concerned with but I understand something else may be causing these to be ineffective.

 

Essentially, I want exactly the same redirection for 'salons' as I have for 'profiles and username mapping' (that already works), except the salons are under the /salons/ directory, and usernames and profiles are under root.

Edited by BenWeston
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.