No trailing slash on URLs , no Redirects!

Problems with the Windows version of XAMPP, questions, comments, and anything related.

No trailing slash on URLs , no Redirects!

Postby markosjal » 12. July 2021 21:07

I am looking to reproduce the behavior I got with the PHP development server which allowed me to load for example
Code: Select all
http://myserver/directory

and get
Code: Select all
http://myserver/directory/index.php


I need to do this without redirects.
The only way I have found to do this so far is with .htaccess. All other solutions seem to produce a redirect!

My .htaccess is now is as follows:

Code: Select all
DirectorySlash Off

RewriteEngine On
RewriteRule ^eSCL/ScannerStatus/?$ eSCL/ScannerStatus/index.php [L]
RewriteRule ^eSCL/ScannerCapabilities/?$ eSCL/ScannerCapabilities/index.php [L]
RewriteRule ^eSCL/ScanJobs/?$ eSCL/ScanJobs/index.php [L]
RewriteRule ^eSCL/Scans/?$ eSCL/Scans/index.php [L]
RewriteRule ^eSCL/Scans/NextDocument/?$ eSCL/Scans/NextDocument/index.php [L]
# RewriteRule ^eSCL/ScanJobs/.*/?$ eSCL/ScanJobs/.*/index.php [L]
# RewriteRule ^eSCL/ScanJobs/.*/.*/?$ eSCL/ScanJobs/.*/.*/index.php [L]

this works fine except the last two commented lines. You see I have some directories that are generated randomly with UUIDS
they look like this:
Code: Select all
/eSCL/ScanJobs/267d04d6-70dc-4693-8d96-063391ec4066

I need to access this like this
Code: Select all
/eSCL/ScanJobs/267d04d6-70dc-4693-8d96-063391ec4066

and get the index.php contained in the directory named by UUID . THESE ARE RANDOM UUIDS! I need a wildcard solution.
I also have:
Code: Select all
/eSCL/ScanJobs/267d04d6-70dc-4693-8d96-063391ec4066/NextDocument

Which here again I want to get the index.php there the "NextDocument" folder. The "NextDocument" is a fixed name but the UUID wildcard remains.

Any help on this?
markosjal
 
Posts: 14
Joined: 27. May 2011 08:41

Re: No trailing slash on URLs , no Redirects!

Postby Nobbie » 12. July 2021 23:03

Actually you are doing plain nonsense. Simply read the Apache Doc about DirectoryIndex, which does the job.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: No trailing slash on URLs , no Redirects!

Postby markosjal » 12. July 2021 23:18

If you mean "DirectoryIndex Directive" this is what the docs say but note again the trailing slash. It does not apply to URLs without trailing slash!

https://httpd.apache.org/docs/2.4/mod/mod_dir.html

So please tell me why you claim I am asking "nonsense"?

Nonsense seems to be your reply as that behavior explained in DirectoryIndex Directive is exactly the behavior I am getting already as long as the trailing slash is used. I need that behavior WITHOUT trailing slash.

Do you get points for posts regardless of them being nonsense? Maybe you like to "look" like an expert because you have so many posts regardless of the nonsense contained in them?

If your knowledge were worth anything you would have explained said use of the directive. Instead you elude to a vague "answer" that does not take the question into account.
markosjal
 
Posts: 14
Joined: 27. May 2011 08:41

Re: No trailing slash on URLs , no Redirects!

Postby Altrea » 13. July 2021 08:13

DirectoryIndex works without trailing slashes because DirectorySlash adds the trailing slash. But to do so it fires a HTTP status 301 redirect.

Thats why DirectorySlash is set to off here. the requirement was: no redirects.
There are some reasons to do so in unattended environments like scheduled tasks or apis.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: No trailing slash on URLs , no Redirects!

Postby Nobbie » 14. July 2021 12:11

Code: Select all
RewriteEngine On
RewriteRule ^(.*[^/])$ $1/index.php [L]


Should do it for all cases.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 83 guests