Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: .htaccess rewrite help |
|
Author |
|
kiwis
Joined: 26 Aug 2016 Posts: 1 Location: Auckland
|
Posted: Fri 26 Aug '16 7:54 Post subject: .htaccess rewrite help |
|
|
I have a folder on my server. It has an .htaccess file which rewrites my url ../WS/index.php?ID=23 to be just ../WS/23
Code: | RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$1 [nc,qsa] |
I have 2 questions
1. How can I handle optional additional vairables? such as index.php?ID=23&Action=z
2. How can I have index.php but also getMember.php and findMember.php in the same folder and rewrite those URL's also?
I've searched for this but have found no answers. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Mon 29 Aug '16 12:20 Post subject: |
|
|
The QSA Flag is Query String Append. So all query string will be added to the URL.
I suggest to use the rewriting like
Code: |
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA]
|
and do the regex check for the name inside your php script.
it might be an option for you to call getMember.php by require 'getMember.php'; in your index.php if the options of the url match. |
|
Back to top |
|
|
|
|
|
|