I just transferred my local web app to my server, and now I'm getting this error:
Parse error: syntax error, unexpected
T_OBJECT_OPERATOR in
/nfs/c05/h01/mnt/71658/domains/ergo-metric.com/html/application/libraries/Survey_form_processing.php
on line 172
This is odd because it works locally! I changed my db settings to the production server, and my base_url is correct.
Any ideas what this could be?! I'm a little worried b/c this is a live site!
I would start with your php config file, check what is enabled on your end and what is enabled on the other end. but first check your config file and look for rewrite short open tags switch it to true. these are very basic but you didn't give a whole lot of information, maybe post a few lines of code before and after 172 let me see what is going on there. also if you are using htaccess files and are still using the default CI example i would switch it to this works like a charm: this is a universal htaccess file no matter your setup you dont have to change it promise you that the best thing since sliced bread.
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
i am going to be on for a while if you reply maybe we can get this worked out for you two heads are better than one thing you know
Related
I am currently having an issue using the URL manager and/or the apache mod_rewrite or maybe something else entirely.
With showScriptName set to false, navigating to addresses such as domain.com/login, domain.com/logout, domain.com/site/login are all behaving the same way. It simply shows the main site/index, as if I were to navigate to domain.com/eeofjew9j8jfdedfmewf (jibberish).
Maybe it's an issue with my Yii settings? Here are those (sorry for the sloppiness):
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'login'=>'site/login',
'logout'=>'site/logout',
'register'=>'users/register'
),
,...
Here is how I have my .htaccess setup in the www root:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I am using a VPS server, so I have root access to make any changes needed to apache. I've checked my phpinfo and mod_rewrite is running and enabled. In my apache config, I have for my www directory:
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
I've been scratching my head on this issue through 3 different hosts (godaddy, dreamhost, and lithiumhosting) so I'm assuming it's an issue on my end with this. Now that I have a VPS though, I'm hoping I can finally figure out my issue and solve it.
First verify that the server is parsing the .htaccess file. This is simply done by placing random text in the .htaccess file such as
CREATE AN ERROR
If this gives you a server error then the file is being parsed. You may have to move the .htaccess file up a directory to get this to work.
After this is working check to make sure the rewrite module in Apache is on. First check phpinfo and look for the running module. If not you may have to delete the comment (#) character in front of the module.
After the module shows up in phpinfo then see if you can do a basic rewrite to make sure that there are not problems with Apache.
RewriteEngine on
RewriteRule ^ http://google.com/? [L,R]
If that is not working try adding the
Options +SymLinksIfOwnerMatch
to the file
Once you have Apache doing it's part now it is up to yii. This code:
RewriteEngine On
RewriteBase /mybasedirectory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
adds the rewrite base option which may be necessary if you do not have the files in the document root such as htdocs
finally if that does not solve the problem then limit your rule to a simple rule such as
'contact'=>'site/contact',
and see if at least redirects to where you think it should. Of course you may have to check the basic rules of .htaccess again to make sure that overide is allowed and there isn't an errant .htaccess in a subdirectory. I hope that helps. I finally got mine working.
What happens if you delete these lines!
enter code here
# otherwise forward it to index.php
RewriteRule . index.php
if you add this code see if it works
'<action:(login|logout|register|contact)>' => 'site/<action>',
I have been looking through questions and answer for days trying to figure out how to make this work.
So far I can get my URL to change, but it won't load the page.
I have to take
http://www.mysite.com/index.php?mode=about
And have it show up as
http://www.mysite.com/about/
So far I have the following code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^mode=(.*)
RewriteRule ^ http\:\/\/\www.mysite.com\/%1? [R=301,L]
RewriteRule /(.*) /index.php?mode=%1 [L]
I have changed things multiple times and nothing. Most site seem to tell me I don't need the 301 redirect but then I can't get anything to work.
For (your) example, once you've properly routed from mysite.com/index.php?mode=about to mysite.com/about, it's now going to look at mysite.com/about/ to find what comes next (index.py/index.html/etc).
Because there is nothing at /about/, you're getting a 404 error.
I don't think you can use mod_rewrite to do exactly what you're trying to achieve, without having some handling within /about/ to actually display the page you want once you get there.
http://www.noupe.com/php/10-mod_rewrite-rules-you-should-know.html
Remember the Filesystem Always Takes Precedence
The filesystem on your server will always take precedence over the
rewritten URL. For example, if you have a directory named “services”
and within that directory is a file called “design.html”, you can’t
have the URL redirect to “http://domain.com/services”. What happens is
that Apache goes into the “services” directory and doesn’t see the
rewrite instructions.
To fix this, simply rename your directory (adding an underscore to the
beginning or end is a simple way to do that).
I have to take
http://www.mysite.com/index.php?mode=about
And have it show up as
http://www.mysite.com/about/
There are two very common types of rules that people want and your statement can be interpreted two ways which require different rules. I'm going to interpret your statement that you have a real, operational script at http://www.mysite.com/index.php?mode=about, but instead of having the user enter that "ugly" URL, you want them to be served that URL when they enter http://www.mysite.com/about/. To accomplish this, you would do the following:
RewriteRule ^about/?$ /index.php?mode=about [L]
Because of the potential for misunderstanding, it's best to state what you want as (1) What the user will enter into their browser and (2) what real file you want to serve them.
I don't believe you need lines #2 & 3 & you seem to have % instead of $, try:
RewriteEngine on
RewriteRule ^([^\/]+) /index.php?mode=$1 [L]
Solved the problem. Thanks for all the help.
#< IfModule mod_rewrite.c>
# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
#< /IfModule>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?mode=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?mode=$1
You can use this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
RewriteRule ^([^/]+)/$ /index.php?mode=$1 [L]
Where the beginning still allows for other folders to be accessible.
I had a mod-rewrite rule that worked just fine for a few months:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
(this is located in site/folder).
This would redirect people from site/folder/something to site/folder/index.php?q=something, leaving the url nice and pretty.
Now, suddenly, while nobody touches the .htaccess file nor the code of the relevant pages, it has stopped working. While the urls stays the same as before, the content of the page is of site/index.php instead of (site/folder/index.php?q=something).
How can I debug this, what tools will allow me to follow the flow of the redirection rule?
In the server or vhost config, you can add these lines:
RewriteLog /tmp/rewrite.log
RewriteLogLevel 5
Then you can look at the output written to /tmp/rewrite.log (or wherever of your choosing) to see what mod_rewrite is doing in real-time. If you don't see any output, then the rules you have aren't being applied at all (possibly the override has changed or mod_rewrite isn't loaded?).
I have a site that until a few days ago was working perfectly. It's setup in different sub domains, etching using codeigniter. The main website is fine and working well, however the admin us domain has all of a sudden begun to display 500 errors when I login.
I can access the different areas of it by typing the address eg
However when I return to the main page http://admin.mysite.com it kicks out a 500 error.
In the same way when I try to submit an article to be published on the site the same 500 error occurs. It seems that whenever I need to use a controller it generates a 500 error.
I don't think it's the htaccess, it hasn't changed at all (indeed I've tried to restore the whole domain from backups) and the 500 error persists.
I've toyed with the idea of an apache problem but mod_rewrite is set, indeed as the site on the main domain is still functioning this makes it even more puzzling.
Can anyone push me in the right direction. As ever with these things I hope I'm asking the right questions. I have been trying to fix this for two days straight and I'm at a loss!
EDIT: I have managed to produce an error finally:
Fatal error: Uncaught exception 'Exception' with message 'GAPI: Failed
to request report data. Error: "GDatainsufficientPermissionsUser does
not have sufficient permissions for this profile."' in
/var/www/vhosts/dealersupport.co.uk/admin/application/third_party/analytics/gapi.class.php:218
Stack trace: #0
/var/www/vhosts/dealersupport.co.uk/admin/application/modules/analytics/libraries/analytics_lib.php(86):
gapi->requestReportData('20924509', Array, Array, Array, NULL,
'2011-12-23', '2012-11-23') #1
/var/www/vhosts/dealersupport.co.uk/admin/application/controllers/home.php(34):
Analytics_lib->get() #2 [internal function]: Home->index() #3
/var/www/vhosts/dealersupport.co.uk/admin/system/core/CodeIgniter.php(359):
call_user_func_array(Array, Array) #4
/var/www/vhosts/dealersupport.co.uk/admin/index.php(202):
require_once('/var/www/vhosts...') #5 {main} thrown in
/var/www/vhosts/dealersupport.co.uk/admin/application/third_party/analytics/gapi.class.php
on line 218
EDIT 2: And this:
Fatal error: Cannot access protected property MY_Form_validation::$CI
in
/var/www/vhosts/dealersupport.co.uk/admin/application/modules/news/controllers/news.php
on line 459
EDIT3: and for the sake of completeness here is the htaccess
Options +FollowSymLinks +SymLinksIfOwnerMatch RewriteEngine On
Options -MultiViews
Prevent access via browsers to all htaccess files. order allow,deny deny from all
RewriteEngine On
# Shortcut globally accessible design locations, to hide true
location # of these files from users. RewriteRule
^(css|js|images)/(.*)$ application/assets/$1/$2 [L] RewriteRule
^modules/([a-z_]+)/(css|js|images)/(.*)$
application/modules/$1/assets/$2/$3 [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>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php </IfModule>
# Turn off ETags, to improve performance.
Header unset ETag FileETag None
Prevent directory listing. Options -Indexes
Maybe it's not the same issue, but I had in the past some error 500 in CI for some controllers because the encoding of the PHP controller files was somehow corrupted.
The only solution was recreating the controller (new PHP file, copy the code ...).
I had the same problem today and i resolved it by changing in .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note:
RewriteBase / was important for me.
I can't seem to get past a Bad Request error while setting up mod_rewrite. I've been trying for a while, so here's what I have.
The url I'm trying to access is:
gordons.local/brewCalc
The page I'd like to see is
gordons.local/index.php?page=brewCalc
Here's my rewrite rule:
RewriteEngine on
RewriteLog /var/www/gordons.com/logs/rewrite.log
RewriteRule ([^/]+)/?$ index.php?page=$1 [L]
I've used a regex tool, and this tool, but no matter what I end up with a page that says:
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.12 (Ubuntu) Server at gordons.local Port 80
Also, I'm not getting any information in my access, error or rewrite logs.
EDIT: My rewrite rules are in my vhost file. (/etc/apache2/sites-available/gordons.local)
In case anybody ever finds themselves here, my issue was a missing leading slash before the replacement.
RewriteRule ([^/]+)/?$ index.php?page=$1 [L]
Should have been
RewriteRule ([^/]+)/?$ /index.php?page=$1 [L]
Grrrr....
If you see Apache's error.log you would be able to see the actual error. Most likely you are trying to put above rules in .htaccess file and RewriteLog is not allowed in .htaccess file. Also your RewriteRule will redirect more than you intend. So if you comment out your RewriteLog and have your RewriteRule like this then it should work:
RewriteEngine On
RewriteBase /
# request is not for a file
RewriteCond %{REQUEST_FILENAME} !-f
# request is not for a directory
RewriteCond %{REQUEST_FILENAME} !-d
# forward to index.php
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA,NC,NE]
NC - Ignore case comparison
NE - Do not encode RHS URI
QSA - Append existing Query String into new one
L - Mark it last rule