I changed the origional rewrite rule to this
RewriteRule ^([a-zA-Z]+) software-connection/public_html/index.php?name=$1 [PT]
...
And would it be possible that there is a way for it to work without having to add the software-connection/public_html. Im guessing not.
So the .htaccess and index.php files are in C:/Program Files/xampp/htdocs/software-connection/public_html/? If you remove the RewriteBase (you should anyway) a relative path would probably work, too.
Also, you could set up your test server to allow multiple document roots: FAQ:
Testing many websites on your development computer/server.
Btw, you said it was a badly written htaccess in the first place?
I am quite picky as you will see.
- Code: Select all
^([a-zA-Z]+)
This means the rule will match
any URL that starts with a letter, you probably want to limit it a bit more than that.
- Code: Select all
!index.php
This means it will not match any URL that contains "index
anycharacterphp". Notice the
anycharacter because the "." is a special regular expression character matching any character. If you want to only match a literal "." it needs escaping with a "\", ie. "\.". Also, the "index
anycharacterphp" can appear anywhere, eg. newindex.php5.
- Code: Select all
!^.(jpg|gif|css)
Because of the ^, which means the beginning, and the fact you are using REQUEST_URI which always begins with a /, this will (! not) match /jpg*, /gif* and /css*. I'm guessing you wanted to match file extensions.
- Code: Select all
!(INNOmgr|templates|balk|Image|pages|afbeelding|medicmail|Medi-Mail)
Again, these will match anywhere in the URL, so a request to /specialpages would not get rewritten. I'm guessing these a sub directories?
- Code: Select all
[PT]
The PT flag does not work in .htaccess files. You should use the L (Last) flag instead so the processing stops when the rule matches and possibly the QSA (Query String Append) flag so query strings are passed on, eg. /abc?def=ghi to index.php?name=abc&def=ghi.
If so, what would be best to rewrite this too?
That depends on what you want to match.
If you only want to match /
letters then
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond $1 !^(INNOmgr|templates|balk|Image|pages|afbeelding|medicmail|Medi-Mail)$
RewriteRule ^([a-z]+)/?$ ./index.php?name=$1 [NC,QSA,L]
should be fine.
Edit: changed RewriteCond in last [code].