Creating tidy URL's using htaccess and php script included

Lightwalker used Ask the Experts™
Dear Experts,

I am having trouble getting clean url's on my files. I understood that it was complex to do and so I wanted to make it as easy as possible. I purchased a script which is designed to make it easy but I found the help documents hard to understand and was hoping to get some guidance. I have included the files and documentation with this request. The author of the script is away on holiday and so I can not ask for his help.

The script came from here

I am wanting to change a url from:




which this script promised to do with ease. I got frustrated and has another go with a different method which was this in the .htaccess file

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^member/support/ticket/([0-9]+)/?$   member/support/ticket.php?r=$1    [NC,L]    # Handle product requests

This method when I go to http://curalarge/member/support/ticket/13/ strips out the css and some of the dynamic content.

I am using this on a testing server using MAMP.

If anyone could put together a working example from the script for the URL I included above I will be very grateful.

All files that have a description starting with Demo 1 are the demo that was provided for me to learn from.

Thank you as always help.html install.php Routing.php important.txt index.php home.php news.php profile.php Routing.php install.php
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Your effort looks close, but you may need to be more specific with the target by adding a forward slash:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^member/support/ticket/([0-9]+)/?$   /member/support/ticket.php?r=$1    [NC,L]    # Handle product requests

Without this forward slash, the rewrite will rewrite paths based on the directory of the current path, which may not be the root directory in the case of CSS files, etc.


Hi HackneyCab,

I am afraid the same thing occurs. The css has been stripped out
Sorry, half asleep here.

The problem is that your page is actually located in a script at /member/support/ but the web browser thinks the visitor is on a page located at /member/support/ticket/13/ so any relative paths in your HTML (paths which don't begin with either "http:" or a forward-slash representing the document root) will no longer point to the correct place, so the web browser will ask for files from the wrong directories.

You can either create rewrite rules which correct this, or you can make your CSS, image, and page links absolute or root-anchored paths (beginning with "http:" or a forward-slash representing the document root).
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.


Thanks, that makes sense, my problem is. being on a testing server if I change my paths to be absolute. when I upload them to my actual server I will have to change them again to the domain name. To add insult to injury this is a redesign and will be hosted on a new server and will need to be tested using the IP address until it is ready and I can change the DNS which mean I might have to change the paths 3 times.

Is there a way in PHP that it can always looks up the root directory or is there a better way where I won't have to change it 3 times for all pages

Many thanks again
You could try using a Rewrite instead:

RewriteRule    ^member/support/ticket/[0-9]+/(.+)$   /member/support/$1    [NC,L]    # Rewrite requests for accessory files (CSS, etc)

I've never tried this, however, as I don't actually use "pretty" URLs. (I'm not sold on their SEO benefits, nor do I prefer the look of them.)

If you wanted to limit this rule to CSS, JavaScript and images only, you might change it to:

RewriteRule    ^member/support/ticket/[0-9]+/(.+\.(?:css|js|png|jpe?g|gif))$   /member/support/$1    [NC,L]    # Rewrite requests for accessory files (CSS, etc)


very helpful

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial