In-spite of going through all the resources about rewriting URL, I am not able to successfully apply the same to my site.

The URl is www.mysite.com/Client/?clientname=name

I want it to be www.mysite.com/Client/name

Client is another directory inside the root directory.

Currently I have

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} Client/ [NC]
RewriteRule (.+) index.php?clientname=$1 [L]

Please help.

Maybe put /client/ in front of the index.php? No idea though, not so good with URL rewrites :).

Working on the basis that your directory and file structure is as follows:

/
    .htaccess
    Client/
        index.php

Try:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule Client/([^/]+) Client/index.php?clientname=$1 [L]

You may also need to disable MultiViews, as the Client directory may be getting matched by mistake. You can do this by adding Options -MultiViews after RewriteEngine On

My Direcory Structure :-

/ (root directory)
.htaccess
index.php
style.css
        Client / (Sub Directory)
        index.php
        style2.css

Will the solution work for the above structure?

It should do. Try it and re-post any output and/or errors.

It would also be helpful if you added the following to the index.php in the Client directory for debugging purposes:

var_dump($_GET); die;

Maybe put /client/ in front of the index.php? No idea though, not so good with URL rewrites :). Woops, double post, sorry!

I tried www.mysite.com/Client/name but it gives -

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

What's the content of your .htaccess file, and what does the server error log show?

Options +Indexes

RewriteEngine On
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule Client/([^/]+) Client/index.php?clientname=$1 [L]

how can I see the server error logs?

Try swapping lines #1 and #3.

Server logs - it depends how your server is configured. Try the above first.

Nops - Same Error

Okay. Can you comment out or remove the Options +Indexes line?

Beyond that, you'll need to post the error from the log. If you don't know where to find the logs, can you post info about your server setup? Or if it's a hosted server, with control panel, you should be able to find the logs via the control panel itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.