0

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.

3
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by blocblue
0

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

Edited by blocblue

0

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?

0

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;

Edited by blocblue

0

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

Edited by minitauros: Double post

0

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.

0
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?

0

Try swapping lines #1 and #3.

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

Edited by blocblue

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.