I have just had a problem with a Codeigniter site where, after the hosting company had migrated files to a new server, I could no longer navigate away from the home page. I Googled a forum with a similar issue and the answer was my htacess file. It was previously like this:
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
and the given solution was to add a '?' character after 'index.php'. I did that and everything then worked OK.
I have tried hard to understand htaccess code and syntax and read many documents but they might as well be written in Chinese for all the sense I can get out of them. So can anyone explain why that additional '?' was needed and what it did? And if you can explain the rest of the code too I would be eternally grateful!
Your new host's php handler or webserver isn't setup to handle PATH INFO, or the stuff after the script (index.php) that's part of the actual path, e.g.
/index.php/this/is/part/of/the/path_info
The index.php script is executed, and everything after can be fetched via "PATH_INFO". If the server doesn't handle this, code igniter can optionally handle the path passed in as the QUERY STRING. Which are parameters that follow a ?.
None of this has anything to do with htaccess or mod_rewrite. It's just the way URLs and handlers work.
Related
I have been looking at this issue for a few hours. I looked at many Stackoverflow posts, and I couldn't find the solution to my problem.
I scrapped my website a few months ago, and just started a new one shortly thereafter. However, my website does not seem to accept PHP. I don't know if the issue is with the server (when I renewed my hosting), or something else. Even calling an external PHP file, using the include function, does not work.
Anyhow, after placing the following code (along other simple coding), I see this in my PHP file when I browse the source code - meaning PHP is not working:
<?php phpinfo() ; ?>
Also, my htaccess file says the following (but I honestly have no clue what any of it means. Though I always hear people say that this file can make a difference:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
It is a bit hard to understand what the actual cause is. Do you run your own webserver? If so, is it apache httpd or IIS? If you have an external hosting partner, they should be able to help you.
Why do you have a htaccess file? You only need it for things like redirect rules. If you don't use that, delete this file or empty it.
Installation of LAMP stacks :https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
I need help with something I don't understand.
I am developing a website for a customer.
I am doing on local, and every day upload to the server all changes and new things.
Last I done is create a simple way to extract the section, parameters and values from url. Is something like:
http://mywebsite.com/product/color/red
Really is not a shop, but this example shows clearly I want to tell you.
The idea is that I have a folder with the sections (product.php, home.php, contact.php, ...) and the section on url says the file to use.
This is working on my computer.
But now I've uploaded all files (literally) to server and not is working.
Shows me a 404 error.
I think the problem is into .htaccess and the PHP versions (I works on php 5.5.10 on local, and server runs on 5.4.16).
This is .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?params=$1 [QSA,L]
</IfModule>
I don't know if you need something more information about all this. If you want, say it and I show you.
I hope you can help me.
Thank you!
UPDATE 2015 July 02
I tried a lot of thing and none worked.
Finally I tried to redirect to google, but not works. And I tried even break it with some wrong code into .htacces, but neither.
Searching I've read that the problem is AllowOverride is none.
For this I tried:
<Directory "/var/www/sites-public/laceart.cadt.com/html/">
AllowOverride All
Allow from All
</Directory>
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]
Still not working. But I don't know if Document Root is correct.
Can someone to help me?
I'm having some issues figuring out how to use an htaccess file. I've got apache/php installed on an ubuntu system and mod_rewrite is turned on (php_info() states that it's in the list of loaded modules). The web server works, displays html and php files, so I'm happy with that.
What I'm trying to figure out now is how to use an htaccess file properly. I created a directory, /data, with an index.php file in it. All I want it to do at the moment is just display the $_REQUEST variable so I can see if things are working the way I assume they should.
Example: If I type in the following URL: localhost/data/info1/ I want the htaccess file to access localhost/data/index.php?request=info1
However, no matter what I enter in to the htaccess file, I keep getting 404 errors, and I'd like to understand why.
Here's my htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule data/(.*)$ data/index.php?request=$1 [L]
</IfModule>
I've made no changes to the config file, to activate mod_rewrite, I used the ubuntu a2enmod command so ubuntu did it for me. After that, I restarted apache.
What I can't figure out is why this doesn't work. My assumption is that there's still some sort of configuration I need to do on the server end, but I honestly don't know what. Is there any advice anyone can offer me?
Here's the fix:
RewriteRule ^data/(.*)$ data/index.php?request=$1 [L]
(You were missing a ^)
EDIT:
In the OP, you have another leading / in the URL example, in this case it'd be:
RewriteRule ^data/(.*)/$ data/index.php?request=$1 [L]
Just looking for a bit of help with Tinybrowser - I've tried updating it to the latest version but it's still failing. If I click the 'Upload' tab I get a 404.. I'm thinking it's possibly to do with the htaccess, but I'm not too hot with htaccess rules so I can't pinpoint it.
If I visit the page directly (/admin/javascript/tiny_mce/plugins/tinybrowser/upload.php?type=image&tokenget=315af6ee7cf85bc6170760a0c1a5b86d&folder=) I get a 404 as well. If I take off 'folder=' it'll go to the page, if I make it follllder=, it'll go to the page. So for some reason 'folder=' seems to be causing problems. Even if I manually put in a string for the folder var.
The htaccess is as follows:
# default
Options All -Indexes
RewriteEngine On
RewriteBase /
# Make sure there's no way of getting to this file
<FilesMatch "\.htaccess$">
Order deny,allow
Deny from all
Satisfy all
</FilesMatch>
RewriteRule ^login(/*)$ system/login/ [L,QSA]
# Route all other traffic to index.php (front controller)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?_args=$1 [L,QSA]
AddType text/x-component htc
If I remove
RewriteRule ^(.*)$ /index.php?_args=$1 [L,QSA]
I end up getting a 403 forbidden error, but obviously it's not really feasible to remove this line anyway.
Thanks in advance guys
I just ran into this as well.
The problem appears to be a security restriction on some servers that relates to the filename of the PHP file, as well as the "folder=" querystring.
I got around it by renaming upload.php to upload_tab.php, and then modifying tinybrowser.php to reference the upload_tab.php file:
if($tinybrowser['allowupload'])
{
?><li id="upload_tab"><span><?php echo TB_UPLOAD; ?></span></li><?php
}
This allows you to see the upload window, and submit some files using POST variables.
However, a problem remains...
The particular server I came across also has a similar restriction on a request to upload_file.php with a querystring of 'folder='. There isn't an easy fix for this, apart from decompiling flexupload.swf (which I tried, but couldn't recompile it) so I couldn't fully resolve the issue.
I am trying to perform this type of rewrite
http://sitename/foo/var1/var2 -> http://sitename/foo/index.php?/var1/var2
This is my .htaccess file(placed in the directory foo):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
In my php script I am displaying the values of $_SERVER['REDIRECT_QUERY_STRING'] and $_SERVER['REQUEST_URI']
If I request a URL like http://sitename/foo/bar the values as expected are bar and /foo/bar respectively.
This also works as expected for: http://sitename/foo/admin and http://localhost/foo/bar.
However when I try to access http://localhost/foo/admin (using localhost instead of sitename) the REQUEST_URI changes to /admin/?admin (this is how it displays in the address bar too, i.e http://localhost/foo/admin/?admin)
I searched for any .htaccess files that might be conflicting and also turned on mod_rewrite logging at level 6 but was unable to find any info.
I have no clue what might be causing it. It would be great if I could know what might be causing this, otherwise I might switch to nginx.
Thanks all for replies. This was some weird server configuration error, things seem to be fine on the new VM I installed. #Dan Grossman , thanks for your suggestion about using $_GET, some of my code is simpler than earlier.