I recently upgraded my CodeIgniter app from v1.7.2 to 2.0.2.
I use mod_rewrite to produce clean URLs without index.php e.g. example.com/controller/action. It is working on my local dev server but when I updated my production app all requests to example.com/controller/action result in displaying main page (i.e. index.php).
When I access address like that: example.com/index.php/controller/action it works.
Mod_rewrite is on as it was working fine with previous code version. With 1.7.2 I used $config['uri_protocol'] = "AUTO" but now I switched to "PATH_INFO" because auto resulted in 404.
Because it is working on dev I’m wondering if I missed any deployment step. Any ideas?
There are .htaccess rules I'm using with CI 2:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
<IfModule mod_rewrite.c>
#paths that you don't want to rewrite
RewriteCond $1 !^(index\.php|assets|session|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
I think I had some similar problem and I believe it got resolved by changing permission on my root folder to 777... but that was on XAMPP
Related
I changed the user folder name on my macbook, now I get a 404 when accessing a child page via localhost using my local apache2 server.
I can't 100% guarantee this is what is causing my woes, but that is a major recent change - and since then I can't load interior pages/posts.
eg: http://example.dev/childpage
Homepage loads, WordPress Admin works - just subpages.
Trouble-shooting so far:
Saved Permalinks in the WordPress Admin to regenerate them
Updated /etc/apache2/extra/httpd-vhost.conf
Grepped /etc/apache2/ to verified no old username
Restarted Apache (restarted my computer!)
Grepped /Users/newuser recursively for old username
Followed this post using functions.php and wp-config.php methods and regeneration steps
Verified via phpinfo(); and /etc/apache2/httpd.conf that mod_rewrite is enabled
.htaccess contains typical single site entry
Would be happy to hear from someone who's found the secret key.
Thanks!
Having done all the above steps, and still seeing no success with the typical .htaccess in the docs, I found that adding /index.php/ to the custom slug revives things. This concludes that all hope is not lost and that I just need to take a deeper look at the .htaccess rewrite rules to omit the unsightly index.php.
EDIT:
Answer via:
https://coolestguidesontheplanet.com/403-forbidden-error-wordpress-htaccess/
Add “Options +FollowSymLinks” to your .htaccess file at start of the file:
Options +FollowSymLinks
# 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
Thanks everyone!
I have a site that is live on AWS - Wordpress, latest version, custom theme
It works fine in MAMP on my laptop, but on the live site, none of the pages besides the homepage work with the permalinks as /%post-name%/
I can make the permalinks work if I change them to default.
I don't think it has to do with htaccess, I've tried scrubbing it, we made some edits to it, and that has not made a difference.
Here are the contents of htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ucampaign/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ucampaign/index.php [L]
</IfModule>
I think it has to do with settings in the AWS instance, which I know can get complicated. But I wouldn't know where to look.
Thank you for looking at this, if there's more information needed to figure this out, I will be happy to provide :-)
Looks like a missing mod_rewrite. check apache config for that. Also, make sure Apache is reading the .htaccess file. When I say check to make sure the .htaccess is being read, does the server throw an error when you place junk inside the .htaccess file? What type of OS are you running on AWS?
having issues with what i think is linked to the mod rewrite in mamp.
The rewrite works fine on the live server, but im working locally with MAMP and getting issues.
The problem is linked to this:
I rewrite the following URL:
http://localhost/BuildSanctuary-Dev/viewbuild/64/three-fiddy-z/1
That should rewrite as:
http://localhost/BuildSanctuary-Dev/viewbuild.php?id=64&title=three-fiddy-z&page=1
The issue is that i get a 404 for page not found.
The requested URL /viewbuild.php was not found on this server.
Which it clearly is... but if i visit just /viewbuild.php it works fine.
The rewrite in the .htaccess is:
RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]
Any ideas? I have done the research and everything in the apache conf is showing as Allowing All...
Thanks.
Your rewriterule redirects to /viewbuild.php and not /BuildSanctuary-Dev/viewbuild.php:
RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /BuildSanctuary-Dev/viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]
A mabye better variant would be to put the .htaccess into the /BuildSanctuary-Dev/ folder and use a relative path as redirect:
RewriteBase /BuildSanctuary-Dev
RewriteRule ^viewbuild/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ viewbuild.php?id=$1&title=$2&page=$3 [L,QSA]
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've set up quite a few Silex/Symfony apps, without ever having problems. I now need to work on a shared domain only with htaccess capability.
Following setup on the Silex documentation, along with browsing around, I set up my .htaccess as follows:
(http://silex.sensiolabs.org/doc/web_servers.html)
Website looks like http://example.com/webpath/to/silex/. This file is in /drive/path/to/silex/.htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /webpath/to/silex/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)? web/index_dev.php/$1 [QSA,L]
</IfModule>
This seems to work well, aside from all routing includes the /webpath/to/silex/. IE. Continual NotFoundHttpException: No route found for "GET /webpath/to/silex/home" errors.
My experience with mod_rewrite has been simple and limited; I've spent a while playing around with permatations of the Rule and the Base without any luck.
How can I pass just the end of the URL to the silex app?
Not sure, but check that...
mode_rewrite is allowed (using Bash) :
$ sudo a2enmod rewrite
$ sudo service apache2 restart
you've got a sensible & existing base path value: Is "/webpath/to/silex/" really correct ? Just comment this line with a #, if it's useless to you