How do I remove/fix that Expressionengine adds "index.php" in urls of template groups that has nothing to do with the index page - expressionengine

I'm having a weird issue with expressionengine. I have a website home page which i have created a template group for called "index". Inside index template group theres the index page template which works as expected, www.domainname.com/ goes to the index.php page.
What I have an issue with is if I add other template groups, those urls will look like this:
www.domainname.com/index.php/template_group_name/template_file
I'm not sure what am I doin wrong, as in their docs the url should look like this:
www.domainname.com/template_group_name/template_file
How do I remove that index.php from the domains?

You will need to fix this with your .htaccess file in the root of your public_html.
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

found it, it was hidden somewhere in their manual, anyone else having the same issue, paste the following in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
source:
https://docs.expressionengine.com/latest/installation/best-practices.html#removing-indexphp-from-your-urls

Related

.htaccess to remove a string within a URL

I am working on a website that uses DokuWiki and the website is called MiscWiki.
Currently all of the URLs are structured this way
http://www.miscwiki.org/doku.php/something/something
I would like to use a .htaccess rewrite to remove the doku.php from the URL. I currently have this statement but it is not working.
RewriteRule ^([^/]+)/doku.php/?(.*)$ /$1 [R=301,L]
Thank you for the help on this one.
You can use these rules in your site root .htaccess:
AcceptPathInfo On
RewriteEngine On
## Uncomment next 2 lines only when you want to remove doku.php/ from old links
#RewriteCond %{THE_REQUEST} \s/+doku\.php/(\S*) [NC]
#RewriteRule ^ /%1 [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ doku.php/$0 [L]

edit htaccess to get inside a folder for rewrite rule

After some help from another question i managed to figure out about .htaccess on my website for Friendly SEO links.
My public_html folder contains those files
index.php
.htaccess
buisnessdetails.php
eventDetails.php
My htaccess so far is this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)\ (.*)$ /$1-$2 [L,R=301]
RewriteCond %{THE_REQUEST} /eventDetails\.php\?id=(.+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /eventDetails.php?id=$1&name=$2 [L]
</IfModule>
So when someone clicks an href which has http://sourtouki.gr/123/abc
the htaccess file goes to the
eventDetails.php file.
But now i want it to change like this
i've edited my public_html folder like this
index.php
events(folder)
2.1 eventDetails.php
buisness(folder)
3.1 buisnessdetails.php
So with these changes i want to do the following thing
Changed the href link to
http://sourtouki.gr/events/123/abc
What changes i must do to the .htaccess file so it can understand that if someone pushes the above link, to go to the eventDetails.php which is inside events folder??
And is it going to be editable so i can add also buisness folder inside that rewrite rule?
You can use something like :
RewriteEngine on
RewriteRule ^(.*)\ (.*)$ /$1-$2 [L,R=301]
RewriteCond %{THE_REQUEST} /events/eventDetails\.php\?id=(.+)&name=(.+)\sHTTP [NC]
RewriteRule ^ /events/%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^events/([^/]+)/([^/]+)/?$ /events/eventDetails.php?id=$1&name=$2 [L]

when using htaccess all the internal links are changed

i want to change my website urls exemple www.mysite.com/about.php to www.mysite.com/about/
i'm using this code in my htaccess file
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# End of Apache Rewrite Rules
</IfModule>
i tried this one too
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
it works but all the page content becomes inside the /about/ its like i created a folder that does not exist so all the internal links are changed , if i have a link to post.php it goes to /about/post.php
all the included pages are not working too such as css and images
sorry my english isn't so good .
i finally found what i wanted ,i used this meta tag in the header section
`<base href="http://localhost/mysite/" />`
now everything works
ps: don't use localehost on webhost

HTACCESS redirect /admin to admin.php

I have my nice urls working fine and heading to my index.php page, but I want to add one exception. I would like it if the user types in /admin that they get admin.php rather than index.php.
I have this:
RewriteEngine on
RewriteBase /
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1
I tried adding this to the beginning of the file:
Redirect /admin admin.php
but that doesn't seem to do the trick
Thanks!
Scott
How about RewriteRule ^admin$ admin.php [L, NC]?

Messy HTAccess File Gives Duplicate Homepage

I have the following HTAccess file:
ErrorDocument 404 /index.php?name=404
RewriteEngine on
# Add www. to any link without it
RewriteCond %{HTTP_HOST} ^mydomain\.co.uk$
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
# Set homepage
DirectoryIndex index.php
# Rewrite content pages
RewriteRule ^sub1/([A-Za-z0-9_-]*)/$ index.php?sub1=1&name=$1
RewriteRule ^sub2/([A-Za-z0-9_-]*)/$ index.php?sub2=1&name=$1
RewriteCond %{REQUEST_URI} !^/404/
RewriteRule ^([A-Za-z0-9_-]*)/$ index.php?name=$1
# Make the pages without .php work
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
This has gradually had bits and bobs tacked onto it and I now have a really small change to make, but can't work out how to do it.
The rules are basically there to ensure that all page have www and end in a /.
Most pages are in the form www.mydomain.co.uk/page/ which actually goes to mydomain.co.uk/index.php?name=page. There are two subdomains which pass an extra get param to the index.php.
The problem is that the homepage can be accessed from either www.mydomain.co.uk/ or www.mydomain.co.uk/index/.
How can I modify these rules so that if the user enters www.mydomain.co.uk it redirects to www.mydomain.co.uk/index/?
Try making the modification below to your .htaccess
### Existing Rules
# Add www. to any link without it
RewriteCond %{HTTP_HOST} ^mydomain\.co.uk$
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
##New Rules
#if request for www.mydomain.co.uk
RewriteCond %{HTTP_HOST} ^www\.mydomain\.co\.uk$
#and it is for the home page, then redirect to index
RewriteRule ^$ http://www.mydomain.co.uk/index/ [L,R=301]
##Other Existing rules go here

Resources