404 route redirect on Doc Manager - php

I have a Doc Manager library. I'm having problem with the url routes, The public (frontend) part are on httpdocs with all the stuff (css, js folder, index.php...), and the backend are just on a parent folder. All It's linked to a subdomain.
If I access it on: https://fondodocumental.fundacioncb.es/ it will give 404 error page with redirection on https://fondodocumental.fundacioncb.es/folder/0.
But if I access on https://fondodocumental.fundacioncb.es/index.php it redirect's to https://fondodocumental.fundacioncb.es/index.php/folder/0 and it works. How can I fix it?
My friend have the same system on his domain and work's when he write: http://archivo.maimona.org/, look how it redirect's.
Thanks.

Use .htaccess file for the magic
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Related

Vanilla php files in subfolder with laravel - page not found error

I have a laravel app: https://laravel-app.com
I want to serve custom pages from a folder on the same domain https:laravel-app.com/player/player.php
I have set the .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /player/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /player/player.php [L]
</IfModule>
But when I try and navigate to that page by using this direct url: https:laravel-app.com/player/player.php
I get the laravel routing error: sorry, the page could not be found
Can someone explain how to get around this?
Anything you want accessible you can put in the public folder of your application, which should be the DocRoot/WebRoot. You won't need any special rewriting or rules as it will be an existing file so the server will serve it fine.

Modified .htaccess to hide index.php for a routing engine cause to 404 error

I've created a custom simple routing engine which works base on paths in 'PATH_INFO' in $_SERVER. If the rout matches with any predefined routs, it will call its controller action; otherwise it will redirect to the home page.
$path = $_SERVER['PATH_INFO'];
if (in_array($path, $routs)) {
call_user_func(array($this, $action));// $action is calculated
}
else {
header('location: ./en');
exit();
}
In this case I modified the .htaccess file as below to hide the index.php and my urls be like http://www.example.com/en or http://www.example.com/en/home
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1 [QSA,L]
When I deployed sources to my domain by hitting url http://www.example.com redirects to http://www.example.com/en which is correct; but in response for that redirect it returns a 404 Page not found page!
Everything works fine in my machine localhost but on the web it does not work. The only different on my machine is that in .htaccess RewriteBase is set to my project path as RewriteBase /myrouting/.
If I go to http://www.example.com/index.php/en on the web it works fine; but I don't want the index.php be visible.
UPDATE
I changed my .htaccess as below; now if I hit www.example.com/index.php/en it redirects to www.example.com/en but still with 404 error
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (?!^index\.php)^(.+)$ /index.php/$1 [L,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php(/[^\s\?]+)? [NC]
RewriteRule ^ %1%2 [R=302,L]
I will be thankful if anybody could help me what I've done wrong. I did search and tried different changes on .htaccess with no success.

htaccess redirect wordpress to index2.php

We have a site running on WordPress ada.localhost.com
Now all request to base url (http://ada.localhost.com/) have to go through tracking page (track.com/c/0912321323/?u=xxx) where u parameter is where to redirect user after he is tracked.
I've created a copy of index.php (index2.php) and I want to create htaccess rule to redirect all base url traffic to:
http://track.com/c/0912321323?u=http%3A%2F%2Fada.localhost.com%2Findex2.html (http://ada.localhost.com/index2.php)
Typical WP htaccess file looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any clue on how to set it up and if WordPress allow this configuration?
From what I found WordPress won't work with index2.php.
Solution for this is to write a plugin which deals with it.

Strange server response

I have a sitw built using codeigniter using htaccess. But on some requests are really strange. The include one specific file(trough codeigniter) at the begginning. This happens really often, if cache is tured off. It happens with different files and doens't matter if the file is on filesystem or request goes trough codeigniter. I guess there something up with htacccess, but i'm not sure.I'll include htaccess and screenshot from fiddler on the bottom:
<IfModule mod_rewrite.c>
RewriteEngine on
#Options -Indexes
#Force non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#If image, javascript or css file does not exists, then try application folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(images|js|css)/(.*)$ ./application/$1/$2 [L]
#If javascript or css file exists, send it to minifier
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)(\.(js|css))$ ./standalone/min/?f=$1$2 [L]
#If isn't file or folder then send it to codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 ./index.php
</IfModule>
And as you can see original request is to top-bar-large.png and echoing $_SERVER out from coudeigniter, shows "upper request" is to parim.js. And parim.js should javascript file after all. Any ideas?
PHP_SELF is index.php... so it seems like you are be getting a CI error page on which the js files are included.
By default, codeigniter comes with an .htaccess file in the application directory with Deny all; so anything in those folders will not be publicly accessible (including your images folder in there) unless you've modified it.
Also, make make sure the images exist.

Mod rewrite problem

At the root of my site... www.domain.com . want to add some static pages that the page url can be set from the user.
So if the users set as url profile then full page url should be www.domain.com/profile ..
So far a simple rewrite rule would do the job.
trasnlate it to something like /staticpage.php?tag=profile
The problem that i want some pages like www.domain.com/shop at the root which arent static...
So what can i do if all the requests for the main directory go to /staticpage.php?tag=$1 ?
I recommend using mod rewrite to send everything to your index.php file and using a front controller to do this. It makes it much easier.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
You'll find a lot more help about mod_rewrite on ServerFault as a general rule, but I tend to do this:
RewriteEngine on
RewriteRule ^static.*$ - [L]
RewriteRule ^assets.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule .* /router.php
where "static" are uploaded files, and "assets" are production graphics/stylesheets/js libraries etc.

Categories