Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

[gelöst] .htaccess routen mit PATH_INFO (nicht SMARTY)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Tue Mar 31, 2020 6:48 pm    Post subject: [gelöst] .htaccess routen mit PATH_INFO (nicht SMARTY) Reply with quote

Hallo zusammen,

ich habe folgenden Aufbau bei mir:

Root-Folder:
- index.php
- .htaccess
- ...
- api
-- index.php
-- .htaccess


Und in dem /api/index.php greife ich auf PATH_INFO zu um dann z. B. folgendes aufzurufen:

api/index.php/v1/feed

nun will ich mit der htaccess-Datei aber, dass ich zwar die index.php "verwende", diese aber nicht in der URL angeben muss, also so:

api/v1/feed

Ich schaffe es irgendwie nicht. Hat jemand einen Tipp für mich, wie ich die Regel einbauen muss, damit er im API-Order IMMER nur die index.php aufruft und alles was danach kommt als PATH_INFO nutzt?

Wäre euch sehr dankbar Smile

Ich habe es nun doch selbst hinbekommen, trotzdem danke Smile

Lösung war, ich durfte die .htaccess nicht in den api-Ordner reinhauen und ich musste die RewriteRule in der .htaccess-Datei in dem RootFolder natürlich vor allen anderen setzen. Die Regel lautet nun wie folgt:

Code:
RewriteRule ^api/v([0-9]+)/(.*) api/index.php/v$1/$2 [L]
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Apr 02, 2020 10:31 am    Post subject: Reply with quote

Read about FallbackResource
Don't use RewriteRule if you don't actually want to rewrite request.
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Thu Apr 02, 2020 5:49 pm    Post subject: Reply with quote

Do you have an example for my scenario?
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Apr 03, 2020 1:23 pm    Post subject: Reply with quote

Code:
<Location /api/ >
    FallbackResource /myapp/api-wrapper.php
</Location>

DocumentRoot /srv/myproject/htdocs

<Directory /srv/myproject/htdocs/ >
    AllowOverride None
    AllowOverrideList None
    # ...website common configuration
    DirectoryIndex index.php
</Directory>

<Directory /srv/myproject/htdocs/myapp/ >
    # ...API specific configuration
    DirectoryIndex disabled
</Directory>


https://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/

https://nystudio107.com/blog/stop-using-htaccess-files-no-really

https://httpd.apache.org/docs/2.4/mod/mod_dir.html
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP