Search doesn't work on php file - javascript

I am testing some basic searching on tables without the use of database yet.
The problem is the search is working in the HTML file but failed to work on php file(I am using codeigniter framework).
This is the code on both html file:
<script src="js/search.js"></script>
THis is the code on my CI php VIEW file:
script type="text/javascript" src="application/views/ui/js/search.js">
My htaccess file on the views:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /webs/BCI/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
My base_url function works on my css files, but it just won't load my JS files located on my js folder.
Are there any more configurations needed to load a js file?

You have to store all css, js and image file under public_html folder. And call your file like-
<script src="<?php echo base_url(); ?>js/search.js"></script>

Related

assets not loading on local wamp server using PHP

I'm trying to run a system locally which is built using php. after doing all the configuration the system gets loaded and shown in the browser but all the assets related to UI components are not displayed. I tried different ways to solve it by changing permission in httpd.config file but still it doesn't work. I'm new to php can someone help me with this?
.htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(assets|css|js|paging|test|cronjobs|documents|SOAP|PDF|demo|pages|classes|UPLOADS|HTML|company_logo)/ - [L]
RewriteCond %{REQUEST_URI} !\.(css|jpg|gif|png|js|robots.txt)$ [NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?([^/]*)?$ index.php?&pageid=$1&id=$2&fm=$3&tpe=$4&curPage=$5&sortby=$6&sortbyodr=$7 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?([^/]*)?$ main.php?&pageid=$1&id=$2&fm=$3&tpe=$4&curPage=$5&sortby=$6 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?([^/]*)?$ index.php?&pageid=$1&id=$2&fm=$3&tpe=$4&curPage=$5 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?([^/]*)?$ index.php?&pageid=$1&id=$2&fm=$3&tpe=$4 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/?([^/]*)?$ index.php?&pageid=$1&id=$2&fm=$3 [QSA,L]
RewriteRule ^([^/]*)/?([^/]*)?$ index.php?&pageid=$1&id=$2 [QSA,L]
RewriteRule ^([^/]*)?$ index.php?&pageid=$1 [QSA,L]

I want to redirect all requests to main domain

When write https://new.example.com/course/comptia
and go to source code, write all requests send to index.php in htaccess
then when view url in my source code with plugins alls send to index.php
like App/Assets/... when click on it send me to
https://new.example.com/course/App/Assets/...
course-> not directory how when click to App/Assets/... Send Me
To https://new.example.com/App/Assets/...
To Main domain without query request uri ?
Try with this adding to your .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php
</IfModule>
in ur .htaccess try to do like this example :
RewriteEngine On
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ http://www.newexample.com/$1 [L,R=301]

Problem when my React App is put on the web

I have created my React App, npm run build ... Put my file in filezilla,
but the problem is that I have this error
Not Found
The requested URL /main was not found on this server.
when I go to a page other than https://clickswinner.alwaysdata.net
What are you propose ?
Try creating a .htaccess file and put it at root of your server
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
</IfModule>
Google is your friend
Here is an article about how to fix 404 issues for Filezilla
https://medium.com/#christine_tran/deploying-a-simple-react-application-using-ftp-filezilla-dreamhost-1e5ff6b8abd6

.htaccess file won't work on my node.js app

I have the following .htaccess file located in the root directory of my node.js app:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
My website runs at www.mywebsite.com. When a form is submitted, the page is redirected to a success page:
res.redirect("/success.html");
The problem is, my .htaccess file isn't working properly. I am redirected to www.mywebsite.com/success.html, instead of www.mywebsite.com/success.
I have tried changing my node.js script to:
res.redirect("/success");
But then I get an error page. What am I doing wrong?
.htaccess is only for Apache servers, but you can try something like this:
nodejs equivalent of this .htaccess

Redirect css|js|img|fonts folder using .htaccess

I'm on shared hosting where some website live.
I have to move a ZendFramework2 on this server by adding it in a directory from the root (dir name = site). Controllers and actions are working right but I can't load any css, images or javascript.
Here are my directories :
/root/website1 (example.com/website1)
/root/website2 (example.com/website2)
/root/site (example.com/site)
/root/site/application
/root/site/data
/root/site/library
/root/site/public
/root/site/public/css
/root/site/public/fonts
/root/site/public/img
/root/site/public/js
/root/site/public/.htaccess
/root/site/.htaccess
.htacces in /site folder
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /site/public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/site/public/.*$
RewriteRule ^(.*)$ /site/public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^site/public/.*$ /site/public/index.php [NC,L]
.htacces in /site/public folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /site/index.php [NC,L]
css tag :
<link href="/css/global.css" rel="stylesheet" type="text/css" media="screen" />
Can i redirect /css/global.css to load /site/public/css/global.css ?
Sure, i could change for ...
<link href="/site/css/global.css" rel="stylesheet" type="text/css" media="screen" />
... but i prefer not to change href
Any help is very welcome!
I would create only one .htaccess file to solve all your problems. Please put this into your /root folder and delete the other .htaccess files.
# This first part should be done by the webserver,
# if not than thing about to change you hoster but I put it here:
# Preventing direct access to any .ht file (.htaccess, .htpasswd, etc.)
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
Options +FollowSymlinks
Options -Indexes
# Start to Rewrite
RewriteEngine On
# For all URL starting with /css, /fonts, /img or /js
RewriteCond %{REQUEST_URI} ^/?(css|fonts|img|js)(/.*)?$ [NC]
RewriteRule ^.*$ /site/public/%1%2 [L]
# Redirect all to the Application if not done already
RewriteCond %{REQUEST_URI} !^/?site/public/index\.php [NC]
# but not if the URL starts with css, fonts, img or js
RewriteCond %{REQUEST_URI} !^/?(css|fonts|img|js)(/.*)?$ [NC]
# or if request is a real file
RewriteCond %{REQUEST_FILENAME} !-f
# or if request is a real directory but not the root directory
RewriteCond %{REQUEST_URI} ^/?$ [OR]
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite the rest to the index.php file in your public folder
RewriteRule ^.*$ /site/public/index.php [NC,L]

Categories