Reputation: 101
I used IIS 7 URL rewrite module 2 to convert my .htaccess file to web.config.
when using the .htaccess on my apache server everything works fine. However when I use my web.config on my IIS 7 server, everything goes to hell.
I have 3 admin pages : addcharacter.php, deletecharacter.php, editcharacter.php
the code is :
<li><a href='admin/addcharacter' title='Add Character'>Add Character</a></li>
<li><a href='admin/deletecharacter' title='Delete Character'>Delete Character</a></li>
<li><a href='admin/editcharacter' title='Edit Character'>Edit Character</a></li>
where the problem lies is once i go to the first link:
www.mywebsite/admin/addcharacter -- the first time works fine
if I switch to another link (regardless of whatever link it is) it appends the admin again
www.mywebsite/admin/admin/destination page
i think it's related to the web.config file since that's the only difference.
here is a portion of my config file:
<rule name="Imported Rule 9">
<match url="^logout$" ignoreCase="false" />
<action type="Rewrite" url="logout.php" />
</rule>
<rule name="Imported Rule 10">
<match url="^admin$" ignoreCase="false" />
<action type="Rewrite" url="admin.php" />
</rule>
<rule name="Imported Rule 11">
<match url="^admin/([A-z][a-z]+)/?$" ignoreCase="false" />
<action type="Rewrite" url="admin.php?action={R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
any ideas?
Upvotes: 1
Views: 568
Reputation: 6138
I believe the problem is in your links, not in the rewrite rules. You shouldn't use relative links but absolute links. When you are on www.mywebsite/admin/addcharacter
and you click a link admin/anotherpage
the browser will send a request for www.mywebsite/admin/admin/anotherpage
. That's just how relative links work and there's nothing the server can do about that. You should have the same problem on an Apache server however.
So your links should be:
<li><a href='/admin/addcharacter' title='Add Character'>Add Character</a></li>
<li><a href='/admin/deletecharacter' title='Delete Character'>Delete Character</a></li>
<li><a href='/admin/editcharacter' title='Edit Character'>Edit Character</a></li>
Upvotes: 2