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?
Related
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]
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.
Hello and thank you for taking the time to help me solve my problem. I like to build all of my web projects using a simple MVC Framework I have created along my travels. I seem to be having a problem getting the .htaccess file to work correctly on specific servers.
For example...
If you go to:
http://thomsonbrothersindustries.com/northside/ and attempt to access a page (right now only "About Us" is functional - http://thomsonbrothersindustries.com/northside/about) but as you can see the "about" page just directs you to a 404 Error.
Now, if you go to: (the same site, but on a different server)
http://ericzdisposal.com/northside/
http://ericzdisposal.com/northside/about
everything works fine...
Here is the .HTACCESS file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
My privileges are limited on the server that is currently not working and I'm still working on getting better access to domain tools, but in the meantime I'm just trying to get a better idea of the problem and hoping there might be an easy fix in my future.
In addition to what #bigman suggested, make sure that AllowOverride directive setting is not very restrictive for your website directory. For mod_rewrite to work in .htaccess, you need to set AllowOverride FileInfo, but for testing purposes, you can set AllowOverride All.
Looks like adding the directory into the .htaccess file did the trick!
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ **/northside/**index.php?rt=$1 [L,QSA]
I didn't realize this was important because on the other server it did not matter
Thanks all!
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 playing with mod_rewrite now, and have successfully enabled it.
However, I need to put a htaccess file inside var/www/ in order to achieve what I want, which is to rename Urls simply...
When I place it my website becomes very strange and nothing basically works...
Is there any code I need to put into the htaccess file in order for things to act normally?
Here is the htaccess file I have so far:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/ad\.php
RewriteRule ^(.*)$ ad.php?ad_id=$1 [L]
My DocumentRoot is also set to var/www/ and my entire website root is there... (index.html etc etc)...
What am I missing about the htaccess?
If you need more input let me know...
I suspect that none of your css files, js or images are loaded. Furthermore, none of your links work either. If so, the problem could be in the RewriteRule cause basically that rule is telling apache to pass all requests to ad.php
You need to fine tune your RewriteRule, so that only the ad links are being affected by the rule.
First, by expanding the RewriteRule like this:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} !^/ad\.php
RewriteRule ^(.*)$ ad.php?ad_id=$1 [L]
These 3 lines that I've added are telling apache to apply the rule only if the requested filename is not a directory, an existing file or a symbolic link - this should take care of the static content, such as the css and images. If your other pages where you're links are pointing at, are also physically on the HDD of the server (plain html or php files), should start working again.
But, as I already said on this question of yours (Little mod_rewrite problem) you need to fine tune that rule, so that only ads are being met by the rule and nothing else.
This isn't a complete answer but it will give your more information that can help you.
You can put options on the same line Options +FollowSymLinks -Indexes
Not all hosts allow .htaccess, or not all .htaccess commands. This can cause problems and pages not to work.
Try commenting out everything (using # sign in front of each line), then, starting at the top, uncomment until you find the problem line.