.htaccess blocks images from mobile site aka root/mobile - javascript

I been researching countless topics regarding accessing images when a user is logged into a mobile site. I'll try to explain everything to the point and any help is super appreciated.
I have website (root/index.html) and a mobile version redirected to (root/mobile/index.html) via .htaccess
I have all my subscribers individual folder accounts as followed: (root/1234567, root/1122334, root/9876543, etc..) with their uploaded images inside (root/1234567/image1.png, etc...)
When a user logs into mobile via (root/mobile/login.php) and tries to view an image via JavaScript www.mysite.com/1234567/image1.png it "breaks".
I tried all suggestions in my research, however when I delete .htaccess from root it works so I know the root .htaccess file is the culprit but I do need security on subscribers folders (root/1234567 etc...) but allow access on image files within subsribers folders. I can post both .htaccess files contents of root and root/mobile
Here's my root .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_USER_AGENT}
"android|blackberry|iphone|ipod|ipad|iemobile|opera
mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^((?!mobile/).*)$ /mobile [L,R=301]
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|txt)$">
Order Allow,Deny
Deny from all
</FilesMatch>
ErrorDocument 403 https://www.mysupersite.com/
ErrorDocument 404 https://www.mysupersite.com/
Options -Indexes
And my root/mobile .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://www.mysupersite.com/mobile [L,R=301]
RewriteCond %{HTTP_USER_AGENT}
"!android|blackberry|iphone|ipod|ipad|iemobile|opera
mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^ https://www.mysupersite.com [L,R=301]
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|txt)$">
Order Allow,Deny
Deny from all
</FilesMatch>
ErrorDocument 403 https://www.mysupersite.com/mobile
ErrorDocument 404 https://www.mysupersite.com/mobile
Options -Indexes

Related

how to deploy React App with links in iis server

I have React App with multiple links in it.
When i deploy in server first it is working fine , when i refresh the page it is throwing : "404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. " error.
I have added .htaccess file and tried still same
.htaccess file:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ ./index.html
this solved same problem on my apache server: .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourwebsite.com/$1 [R,L]

Website keeps requesting a 301 URL address

My website is giving me a "This website is not secure" and I can't find the root of it, even though I double checked through everything to see if there are any http and switched them to https. I also have cloudflare forcing https.
I have checked the network tab and found one URL giving me trouble but it doesn't give me much information
The URL is giving a 301 moved permanently. I don't know where in my html I am requesting this site. I even used ctrl + f nothing showed up.
It's just requesting http://mywebsite.com/ but there is nothing I can see in my html requesting a http version of my site. I don't have anything that would cause my website to request http in .htaccess either.
RewriteEngine On
Options -Indexes
RewriteRule ^folder/?$ - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]
ErrorDocument 403 /index.html
ErrorDocument 404 /index.html
ErrorDocument 500 /index.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/403/$
RewriteRule ^(.*)$ /index.html [L]
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /index.html [L]
RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /index.html [L]
Is there something I'm missing?
I found the issue. It looks like it was jQuery that was requesting a http version of my site.
I couldn't ctrl + f it because it was a cloudflare jQuery link.
https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
On line 2727 it was checking using http. (The picture shows https is because I just changed it)
The Fix
Save the jQuery locally and change http to https.

How to send all request to index.html - reactjs

I'm using linux OS and apache.
I created a webapp directory inside public_html. inside public_html I have a landing page. I want to keep this landing page.
all resources can fetch as well.
but I got Page not found error.
I found out that I should send all requests to index.html file.
.htaccess file:
<ifModule mod_rewrite.c>
#######################################################################
# GENERAL #
#######################################################################
# Make apache follow sym links to files
Options +FollowSymLinks
# If somebody opens a folder, hide all files from the resulting folder list
IndexIgnore */*
#######################################################################
# REWRITING #
#######################################################################
# Enable rewriting
RewriteEngine On
# If its not HTTPS
RewriteCond %{HTTPS} off
# Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# Redirect to the same URL with https://, ignoring all further rules if this one is in effect
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L]
# If we get to here, it means we are on https://
# If the file with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
# and the directory with the specified name in the browser doesn't exist
RewriteCond %{REQUEST_FILENAME} !-d
# and we are not opening the root already (otherwise we get a redirect loop)
RewriteCond %{REQUEST_FILENAME} !\/$
# Rewrite all requests to the root
RewriteRule ^(.*) /
</ifModule>
<IfModule mod_headers.c>
# Do not cache sw.js, required for offline-first updates.
<FilesMatch "sw\.js$">
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
but I got not found message error:
https://parsebar.com/webapp/login
I use this snippet in my .htaccess when my react app runs in a subfolder:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

.htaccess causes fail in parsing source maps

On the web page the .htaccess is:
RewriteEngine On
RewriteBase /
Options -MultiViews
DirectorySlash Off
# skip POST requests
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
# redirect to .php-less link if requested directly
RewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.php\sHTTP/.+
RewriteRule ^(.+)\.php $1 [R=301,L]
Options All -Indexes
ErrorDocument 403 /img/error.php
ErrorDocument 404 /img/error.php
ErrorDocument 500 /img/500.png
It causes the next error:
Failed to parse SourceMap: .../js/bootstrap-select.js.map
When I delete it, the error doesn't occur.
How should I modify .htaccess?
Even though you had answered yourself just i want to post this so that others with this issue will know exactly what that happens
Warning:
Do not use .htaccess to redirect error to another HTML/PHP page or server
that isn't your own (such as this error.php). Errors can be replaced
by other images, not with an HTML or PHP page as that might cause indefinite
loop too.
Solved the problem by changing error.php to a picture ( in error.php there was redirect to index page ).

$.post to Codeigniter Controller/Method 404 Page Not Found

I have developed a Codeigniter prototype application and hosted with Godaddy.com during the development phase for testing purposes without issue. This application uses a combination of javascript, jquery, HTML5, CSS and PHP (Codeigniter Framework). This week I have transferred the application to the clients server and have had many configuration issues but finally hit a wall.
The client set up a fresh install on a new Linux/Apache2 server with PHP5. mod_rewrite is enabled and allowoverride is set to all. The Apache2 settings (per the client are)...
My .htaccess script(since this issue I have tried many different .htaccess versions)...
RewriteEngine On
RewriteBase /CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
My javascript code for posting serialized form data to PHP page...
$.post('login_ctrl/authenticateuserlogon', $formData, function($responseData)
{
$userAuthentication=$responseData.userAuthentication;
if ($userAuthentication=='success')
{
window.location.href = "student_portal_ctrl";
}
else
{
$('#loginErrDiv').text('Username or Password is incorrect - Please try again.');
return;
}
});
My codeigniter file structure is...
-root /
/CI
/application
/system
/index.php
/license.txt
/.htaccess
When I post to this controller/method, the browser outputs...
-----EDIT-----
Sorry, forgot to include my config.php settings, here they are...
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; //I have tested the app using all of codeigniters
//default URI Protocols
-----EDIT #2-----
This is the method on the controller that is receiving the 404 error
//AUTHENTICATE USER LOGIN FUNCTION
public function authenticateuserlogon()
{
//SETTING $FORMDATA TO SERIALIZED POST DATA
$formData = $this->input->post();
//Sets the Method for the login_mdl
$modelMethod=$formData['modelMethod'];
//LOADING USER AUTHENTICATION LOGIN MODEL
$this->load->model('login_mdl');
//SENDING FORMDATA TO MODEL AND RETURING DATA TO $RESPONSEDATA
$responseData = array();
$responseData = $this->login_mdl->$modelMethod($formData);
//OUTPUTTING JSON RESPONSE DATA BACK TO JAVASCRIPT
$this->output->set_output(json_encode($responseData));
}
Use this .htaccess which is tested by me and working fine
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
and in your config.php file use this,
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];

Categories