I'm developing a plugin with the latest version of WordPress (3.4.2) locally (XAMPP 1.7.7 [PHP: 5.3.8]) and for some reason the links are not working within the plugin. I just have a simple delete link that links to a 'delete-gallery.php' file from within the plugin admin page. This file (delete-gallery.php) only calls a function to delete the record from the database and redirects back to the page that called it (the plugin admin page). Simple enough. But, when the link is clicked I get directed to XAMPP root (localhost:8080/xampp) and not the requested destination (delete-gallery.php) for some reason.
$url = plugins_url('includes/delete-gallery.php', _FILE_);
echo 'Delete';
I know the hrefs' path is correct on the link because it shows up in the status bar on hover, but for some reason it's not locating the file locally on submission. If I set the destination to somewhere external (ie. google.com, etc) it works fine, but not locally within wordpress.
The permalink structure has been updated and the .htaccess file is currently as so:
# 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
If I use a blank .htaccess file I don't get redirected to the XAMPP root, but instead get the error 'Object not found! The requested URL was not found on this server. ...' when the link is clicked.
Is there something that needs to be set in .htaccess to allow redirecting locally within wordpress? I'm at a loss here. Any suggestions would be greatly appreciated.
It was a simple sytax error. Had single underscores instead of doubles in the FILE parameter.
_FILE_ -> __FILE__
Related
I have used setUrlStrategy(PathUrlStrategy()); to remove # from the url, but since then my pages stopped reloading after I deploy my project on web, it shows 404 page not found. but works perfectly on localhost.
if I remove setUrlStrategy(PathUrlStrategy()); and build again to deploy on web it works. but that # shows on url.
Can anyone help?
p.s: I used my project on non root location, and have already added my project name in index file, my project works if I open first page to next file, but not directly when open next file from url.
ok i found the problem, it was because i didn't use .htaccess file.
here is htaccess code if anyone get same problem.
RewriteEngine On
RewriteBase /myproject/
RewriteRule ^index\.html$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myproject/index.html [L]
</IfModule>
put this file where your index file is.
So I'm setting up a local environment for testing and development. We use CodeIgniter as our framework.
But when I copy the whole server to the local server (I have XAMPP), and navigate to the root, all I see is a directory structure - it doesn't display anything at all that I would expect to see from the website.
I spent 4+ hours (over several days) trying every .htaccess and httpd.conf suggestion I could find on Google, stackoverflow, these forums, and more. I am able to get a 500 server error when adding garbage to the .htaccess file, so I know it's being processed. But I think my problem is possibly unrelated to the .htaccess file settings. (I don't really care if index.php shows up on the URL bar locally.)
There is no index.php on our server's root (again, our site is built with CodeIgniter). Nor anywhere else in the site's directory structure, (except /application/views/user/template/original). When I access the site live, in the URL bar it pulls up the domain name followed by: "/user/login". Looking into the /application/views/user folder shows a login_view.php, but when I try to access it directly, I get an Access Forbidden 403 error.
Per this solution, I also tried changing the DocumentRoot (in C:\xampp\apache\conf\http.conf) from "C:/xampp/htdocs" to "C:/xampp/htdocs/othersites/mysite" Same result.
How is the site loading remotely, but not locally?
Check your base_url in config.php
Here is working .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myproject
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
It turns out, for some reason, the site's root index.php wasn't in the git repo that I cloned from. I have that now, along with another (different) .htaccess file.
After changing the base_url in application\config\config.php to my localhost variant, it's working!
If I ever figure out why they didn't have index.php in that repo, I'll let you all know...
I am working on project using codeigniter for the first time with bootstrap 3.
My application and system folder from CI is located outside my 'project.main' folder. Everything works fine until I try to use .htaccess in my project.
I am using an XAMPP server and I already loaded the rewrite module and as well as the AllowOverride All and restarted my server.
My url now looks like this 'http://localhost/project.main/' ..
Now my question is since I already removed the 'index.php', my navbar links in bootstrap was like this
'<a href='<?php echo site_url("pages/view/about"); ?>
but if I click it I am directed to the url
'http://localhost/project.main/pages/view/about' which gives me
Object not found' error page.
But if I use href=' <?php echo site_url("index.php/pages/view/about"); ?> I am routed to the right page.
Which is the right way of doing it? and under my config.php I have this $config['uri_protocol'] = 'REQUEST_URI '; is it necessary that uri_protocol match what is on the .htaccess under RewriteCond %(REQUEST_URI)..?
What i read in github there are two versions of .htaccess.
You didnt mention changing index page to blank inside config.php ? In case of emergency I give you my simple htaccess. It works when moving application and system folders out of public.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Also try to switch uri_protocol option.
Here's the ultimate solution for index.php How to remove "index.php" in codeigniter's path .
So, I have cakephp installed in what I believed to be the appropriate way for production code with actual cake files above the public_html folder. The app folder is removed from the cake folder and placed at the same level.
Loading the home page works fine with the databases and the debug working.
However, in trying to run some test files I get a 404. Obviously, I need some way to direct something like www.example.com/posts/index to the proper location. I am not sure as to why this is necessary since the index.php file tells cake where the app directory is located?
Also, if I need to use the .htaccess file, how do I point to the proper location and exactly what am I pointed at?
Update - I get the errors when I follow the blog tutorial and navigate to www.mywebsite.com/posts/index
If you have a production install the url example.com should point at app/webroot/, and the only .htaccess file you need is the default one from the webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Be sure to use the .htaccess file which corresponds to the exact version of CakePHP you are using as it has changed over the years.
I have a codeigniter app and i wanted to remove index.php from the URI. so from the codeigniter wiki i used this script.
It stopped working once i change a config, after this change all my urls only returned home page. No matter what link i used, it only gives me the home page of my site. So i reverted it back to index.php but the server still works the same way. I tried deleting the .htacess file completely then update it with the new one which actually works but even then its working the same way. (all urls redirected to home page) Im totally out of clue, on whats wrong with my script or server.
P.S : when using .htacess i did make $config["index"] to be blank.
UPDATE
Now i removed everything else from my .htaccess file and i have only this which is the essential part to remove index.php from uri segment
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Even with only these all my urls are taking me only to the home page. I am clueless as of whats happening.
In your app/config/config.php try changing the value of:
$config['uri_protocol'] = 'AUTO';
to:
$config['uri_protocol'] = 'REQUEST_URI';
If still not working, try the remaining options (PATH_INFO, QUERY_STRING, ORIG_PATH_INFO).
Your ErrorDocument line is inside <IfModule !mod_rewrite.c> which to me looks like you don't have the mod_rewrite module installed. (If you did, that line would be ignored.) The ErrorDocument 404 /index.php line is a hack to get you to the /index.php file in case a request comes in for a file that doesn't exist.
To set the 404 page in CodeIgnitor, you need to edit your routes.php file.
$route['404_override'] = 'general/not_found';
More details.