Expression Engine hide index.php not working correctly - expressionengine

I am working on a site that was working before someone else made some changes to the site. Now, I have to include index.php to the URL before the contact form will work.
Here is the htaccess file code I am using:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
What am I missing here?
Thanks.

The ? after index.php indicates to me that you're running PHP as CGI ... perhaps that was changed?
Also see: https://stackoverflow.com/a/11143216/174299

Related

Point to a file in subfolder with .htaccess

I've wanted to move my index.php file from the root to /system/ folder, this is for no reason but giving myself opporunity to learn more about .htaccess, which I am finding very confusing.
How can I achieve this? Currently my code looks as follows
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?query=$1
This allows for example mydomain.com/some-url/ to become /index.php?query=some-url for example, this far I'm with it all. But moving the file into System folder and addind /system/ before /index.php does nothing. How does one do this? Thanks!
This could be done with a simple rewriterule. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule ^(.*)$ system/index.php [L]

Removing 2 directory and php from url

My current url is:
http://example.org/dir1/dir2/profile.php?username=someone
I want it to look like this:
http://example.com/someone
My .htaccess file is in public_html folder and it is completely empty.
Please, can you help me?
Try this :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /dir1/dir2/profile.php?username=$1 [QSA,L,NC]
The conditions make sure you don't rewrite any existing file/directories on the server.

Remove index.php from url for ONLY CI subdirectory

I get how to remove index.php from CI urls overall. The following works fine:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /crm/v2/index.php?/$1 [L]
However, it interfers with other code on the live site. This new CI version i'm adding is in a subdir named v2. Thus the layout is something like:
-originalDir
--v2
-otherDirs
-.htaccess
-etc...
So in essence urls come out something like:
// Original page
https://www.site.com/originalDir/somepage.htm
// And this exist too
https://www.site.com/originalDir/index.php
// My new stuff
https://www.site.com/originalDir/v2/index.php/controller/etc...
// Desired effect withOUT affecting the original sites index.php page
// aka, the below is what i WANT but NOT getting!
https://www.site.com/originalDir/v2/controller/etc...
I can code in a lot of languages, but never a lot of experience with these htaccess rewrites. Any ideas on how to make it rewrite index.php for ONLY the codeigniter sub-directory? I've tried a few things that seem to work locally, but not on the live server. Not sure the exact structure of rewrite code.
Assuming you want to only rewrite rules in the CI directory, and not point any URLs outside of that directory to it...
Change your RewriteRule to match only URI's that start with your CI directory.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^crm/v2/(.*)$ /crm/v2/index.php?/$1 [L]
Alternatively, you can put an .htaccess file in your /crm/v2 directory, and specify a RewriteBase.
RewriteEngine on
RewriteBase /crm/v2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Have you tried using RewriteBase?
RewriteEngine On
RewriteBase /crm/v2
RewriteRule ^(.+)$ index.php?/$1 [L]
I have not tested this specifically with your information but this is from a template that I use for some of my projects.
Here is the documentation for RewriteBase: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
I hope this helps!

mod-rewrite forwarding without changing URL

I have a small problem with my Apache configuration when creating "pretty" URLs. I've got it to the stage where typing (or linkig for that matter) to
index.html
forwards you to
index.php?pageID=Forside
that is exactly what I want.
But how can I get index.html to stay in the address bar of the browser?
Right now it forwards and changes the URL to the original one.
Here my .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} index\.html
RewriteRule .* http://www.radoor-designs.dk/index.php?pageID=Forside [L]
And before someone comments on it: Options +FollowSymLinks is missing since it triggers an error 500 on a one.com webhotel.
Thanks in advance!
Try the following:
RewriteEngine On
RewriteRule ^index\.html$ /index.php?pageID=Forside [L]
I think this may help you to resolve your problem.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.html$ /index.php?pageID=Forside [L]
This will do the redirect for you whilst showing index.html in the browser window.
Strange that symbolic links creates an error 500,
if you want it to redirect to index.html?pageID=Forside then do
RewriteRule .* /index.html?pageID=Forside [QSA,L,R=301]
I'm not 100% certain what you are trying to achieve with this could you explain a little more?

Expression Engine - htaccess to hide index.php is not working. Why?

I have an MSM install with four (licensed) sites. Three of them work perfectly and behave as they should. The fourth one, currently under construction seems to have a mind of its own. The home page shows up but attempts to add additional templates or template groups with content do not display. I only get
The requested URL /template-name/ was not found on this server.
I double checked and made sure the Enable Strict URLs was set to No and the templates are all synched properly. At this point I am repeating myself. Any clues?
Edited
I found out that if I insert index.php into the URL the other pages and templates will show, which leads me to believe that I have something wrong with the htacess file.
Here is the code I am using (which has worked just fine for other sites):
# BEGIN ExpressionEngine Rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?$1 [L]
</IfModule>
# END ExpressionEngine Rewrite
Any clues why this is not working correctly?
Turns out it was the htaccess file. I replaced the rewrite noted above with the following and it solved the problem:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

Resources