So I'm trying to get a .htaccess File to work, that remaps some URLs for my Webservices. I've got the following Code in my .htaccess File:
# General Settings
Options +FollowSymLinks -Indexes
Allow from all
AddCharset utf-8 .css .html .php
RewriteEngine on
RewriteBase /
# Option 1: Remove Index.php from URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Custom Options: Webservices
RewriteRule ^applications/([0-9]+)/infobox\.xml$ app/makeInfoBox/$1/ [L]
Removing index.php works just fine, so I assume mod_rewrite is working properly. But why does my Webservice rule not work?
It should remap https://example.com/applications/258/infobox.xml to https://example.com/app/makeInfoBox/258/ or shouldn't it?
When I add the [R] Flag it does work, but I don't want to URL redirected, I want it remapped.
Thanks for your answers!
Edit: So after some Testing I reached the point where I'm really out of ideas. This is my mod_rewrite Code:
# General Settings
AddCharset utf-8 .css .html .php
RewriteEngine on
RewriteBase /
# Custom Options: Webservices
RewriteRule ^applications/([0-9]+)/infobox\.xml$ app/makeInfoBox/$1/ [DPI]
# Option Remove Index.php from URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
I now have logging activated with a high log-level. Here is what is logged:
add path info postfix: /etc/apache2/htdocs/webservices/applications -> /etc/apache2/htdocs/webservices/applications/258/infobox.xml
strip per-dir prefix: /etc/apache2/htdocs/webservices/applications/258/infobox.xml -> applications/258/infobox.xml
applying pattern '^applications/([0-9]+)/infobox\.xml$' to uri 'applications/258/infobox.xml'
rewrite 'applications/258/infobox.xml' -> 'app/makeInfoBox/258/'
add per-dir prefix: app/makeInfoBox/258/ -> /etc/apache2/htdocs/webservices/app/makeInfoBox/258/
strip per-dir prefix: /etc/apache2/htdocs/webservices/app/makeInfoBox/258/ -> app/makeInfoBox/258/
applying pattern '^(.*)$' to uri 'app/makeInfoBox/258/'
RewriteCond: input='/etc/apache2/htdocs/webservices/app/makeInfoBox/258/' pattern='!-f' => matched
RewriteCond: input='/etc/apache2/htdocs/webservices/app/makeInfoBox/258/' pattern='!-d' => matched
rewrite 'app/makeInfoBox/258/' -> '/index.php?/app/makeInfoBox/258/'
split uri=/index.php?/app/makeInfoBox/258/ -> uri=/index.php, args=/app/makeInfoBox/258/
trying to replace prefix /etc/apache2/htdocs/webservices/ with /
trying to replace context docroot /etc/apache2/htdocs/webservices with context prefix
internal redirect with /index.php [INTERNAL REDIRECT]
strip per-dir prefix: /etc/apache2/htdocs/webservices/index.php -> index.php
applying pattern '^applications/([0-9]+)/infobox\.xml$' to uri 'index.php'
strip per-dir prefix: /etc/apache2/htdocs/webservices/index.php -> index.php
applying pattern '^(.*)$' to uri 'index.php'
RewriteCond: input='/etc/apache2/htdocs/webservices/index.php' pattern='!-f' => not-matched
pass through /etc/apache2/htdocs/webservices/index.php
Comparing the log output when redirecting and when remapping shows that it's nearly exact the same.
What am I doing wrong?