I am getting following error after opening the codeigniter base url:
"No Input file specified". I know that it has something to do with htaccess file but can't make it work.
my htaccess file content:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Go daddy directory structure: htaccess file is at root folder of subdomain.
Your htaccess file is fine you need to check paths in controller
i guess it could be view file missing
$this->load->view('file_view', $data);
in views folder it is named "file_view.php"
also make sure file paths are correct
if you are calling a module module file exists under modules folder
check $route['default_controller'] = "frontpage"; in routs.php under config folder for above line frontpage.php must exist in views folder
add rewrite base
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Related
I am creating a small eCommerce website. I want to hide the query string parameters and want to replace them with the forward-slash /. For this reason, I have created the following .htaccess file structure:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ $1.php [L]
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ $1.php?product=$2 [L]
This works in the parent directory http://localhost/ecommerce/index.php?product=43:
http://localhost/ecommerce/43
But if I copy this same .htaccess file in the nested directory product to access the item http://localhost/products/product/index.php?product=43:
http://localhost/products/product/43
It did not work. I cleared cache and cookie as well but still no luck. What can be the issue in my .htaccess file? Thanks!!!
I have a problem with my routes. I have my images in sources/ folder but when the image is missing it cause to load the website and future problem with system overloading.
Htaccess:
RewriteCond $1 !^(index\.php|robots\.txt|sources|uploads|captcha|sitemap\.xml|_gapi|robots\.txt|googleaac809c6bcbeb4e8\.html|googlebaf6b56ae3013092\.html|feeds|temp)
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
This should cause to load files from those folders - working well by this point
But when there is image missing for example:
<img src="uploads/non_existing_image.jpg"> the image wont load but when I copy the URL the website will load correctly and after some time my server ends up with 500 Error.
Is there any way how to solve this in htaccess/php ?
I want to end up with 404 error on that link
Don't use .htaccess for this, just Add the index.html file to your images folder also add the index.html in CSS and JavaScript folder. When someone try load you folder index.html is auto load and didn't allow your images etc.
It will give result like this
i also use a htaccess file with codeigniter, even though mine is quite smaller then yours:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
to explain: RewriteEngine On enables the rewriting of the url,
the RewriteCond %{REQUEST_FILENAME} !-f tells htaccess that the requested file should not be an existing file,
the RewriteCond %{REQUEST_FILENAME} !-d tells htaccess that the requested file should not be an existing directory.
this way you dont need to exclude all the seperate files and/or extentions and/or directories.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Just add this to your .htaccess file
I am new at .htaccess and I have a PHP file called products.php and a folder with the same name called /products.
I want to create a friendly URL for the products page of my website a I would like to know if it is possible to execute the products.php file outside the folder /products.
I am using the .htaccess code below.
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^products/([a-z0-9-]+)/([0-9]+)/?$ products.php?id=$2&nome=$1 [NC]
Thanks
Did you try it and it didn't work ? if it didn't, try removing this line :
RewriteCond %{SCRIPT_FILENAME} !-d
I have a situation where I have a bunch of old content in a /products directory. Moving forward, new content is going in a /product folder. What I would like to do is redirect to /product if a file, or directory doesn't exist.
I have the following in a .htaccess file in the /products folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /product/$1 [R=301,L]
This works well for files in the /products directory and sub directories that contain index.htm files or other file names, however I'd like to limit a redirect on a non existing directory to be 2 levels:
/products/someproduct - Do not redirect
/products/someproduct/anotherproduct
If it doesn't exist, redirect to /product/someproduct/anotherproduct
How do I force the rule to only apply to sub directories that are 2 levels or more deep?
Try the following
RewriteEngine On
RewriteBase /
#for all /products/somefolder/any_folder_level_deeep content
RewriteCond %{REQUEST_URI} ^/products/([^/]+/.+)$ [NC]
#if file does not exist
RewriteCond %{REQUEST_FILENAME} !-f
#and directory does not exist
RewriteCond %{REQUEST_FILENAME} !-d
#redirect to product folder
RewriteRule . /product/%1 [R=301,L]
this is my code at .HTACCESS file in my web server:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
This code works well, but when a directory exists the website redirect to Index of (Apache directory browsing):
For example:
http://www.mywebsite.com/XXXX This redirects to the URL http://www.mywebsite.com/XXXX and the page show information about XXXX. (Directory XXXX doesn't exists)
Directory ZZZZ exists and http://www.mywebsite.com/ZZZZ redirects to Index of (Apache directory browsing)
Finally, the question is how to redirect as 1. example.
RewriteCond %{REQUEST_FILENAME} !-d
This line disables rewriting for existing directories. Simply remove it if you always want to rewrite.