Jump to content

.htaccess query + fixing trailing slash problem


u01jmg3

Recommended Posts

Hi,

 

just wondered if anyone could help me out with this small .htaccess problem and using mod_rewrite?

 

Basically I already have a working .htaccess file but I wondered if there was a way of writing a generic rule for what I have rather than writing a rule for every page of my site in my .htaccess. Here's what I mean...

 

----------------------------------------------------

 

(1.) Here's the current rule for a page on my site:

RewriteRule ^corporate_training$ 14_corporate_training.php

 

(2.) And here's the current rule for a particular section of a page:

RewriteRule ^corporate_training/anger_management$ 14_corporate_training.php?course=anger_management

 

Could this be made generic with one single rule for each?

 

----------------------------------------------------

 

Also if someone uses a trailing slash for any page of my site such as:

 

http://www.realize-scotland.co.uk/corporate.htm/

 

it gives an error - is there anyway of properly interpreting this in the same way:

 

http://www.realize-scotland.co.uk/corporate.htm

 

is properly understood?

 

----------------------------------------------------

 

Thanks. Jonathan.

Link to comment
Share on other sites

Thanks very much for your reply michaellunsford. This is what's now in my .htaccess file but can it be shrunk further???

 

RewriteEngine on
#----------------------------------------------
#Home - Corporate Training - Site 1
#----------------------------------------------
RewriteRule ^home-corporate_training/?$ 11_home.php
#----------------------------------------------
#About Us
#----------------------------------------------
RewriteRule ^about_us/?$ 12_about_us.php
RewriteRule ^about_us/([a-zA-Z0-9_]+)/?$ 12_about_us.php?skill=$1 [L,NS]
#----------------------------------------------
#Corporate Training
#----------------------------------------------
RewriteRule ^corporate_training/?$ 14_corporate_training.php
RewriteRule ^corporate_training/([a-zA-Z0-9_]+)/?$ 14_corporate_training.php?course=$1 [L,NS]
#----------------------------------------------

Link to comment
Share on other sites

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.