This is what is in my .htaccess file right now.
Now I want to eliminate the index.php in my url. How do i do this?
I have tried several possibilities from this website but either i get a 500 internal error or nothing changes at all.
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
The following code will rewrite index.php to index
RewriteEngine on
RewriteRule ^index index.php
Try if this works
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Related
I have a problem with the Rewrite options and I can't find the right answers on the internet so I hope this community can help me.
I am working local on a web project and use XAMPP as my local webserver.
I made a VirtulHost (basic.localhost) and now there is my problem with the mod_rewrite options.
When there is an url: basic.localhost/index.php/var1=option1&var2=option2&var3=option3&var4=option4
I want to rewrite the url to this: basic.localhost/option/option2/option3/option4
The var1 to var4 variables are used as GET variables to select content from an database.
This is my .htaccess now:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
And all Rewrite Rules that I tried does not work...
I found an answer for the problem with the variables:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2&var3=$3&var4=$4 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2 [L,QSA]
RewriteRule ^([^/]+)$ index.php?var1=$1 [L,QSA]
</IfModule>
Now there is only the Problem with the index.php.
I finally got a solution for this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2&var3=$3&var4=$4 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)$ index.php?var1=$1&var2=$2 [L,QSA]
RewriteRule ^([^/]+)$ index.php?var1=$1 [L,QSA]
</IfModule>
I'm working on a CodeIgniter application that was previously developed.
The issue that I'm getting is a page not found and I have installed on wamp.
Here is the .htaccess file that I'm currently using for the app (not the wamp one).
# Turn on URL rewriting
RewriteEngine On
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
How do I go about fixing the 404 issue? Would I change the wamp .htaccess file?
Thank you,
Kevin Davis
# Turn on URL rewriting
RewriteEngine On
RewriteBase /FOLDERNAME/ #Add your foldername in place of FOLDERNAME
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Try using below .htacccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this can help you.
My .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^pharmacy/?(.*)$ /wp-content/plugins/swift-mailer/lib/classes/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
After reading this answer I tried adding RewriteRule ^(.*)\.html$ / [L,R=301] after RewriteCond %{REQUEST_FILENAME} !-d which redirects html files to root folder but other URL stops working.
PS: I am not used to with .htaccess files.
You should put new RewriteRule before RewriteConds because it does not need any condition for redirect.
Moreover, you save working old redirect rules. RewriteCond affects only 1st RewriteRule after it. Placing new RewriteRule after RewriteConds make old RewriteRule be acheived in all cases without any restriction.
So, the fragment of your htaccess should look like
RewriteRule ^(.*)\.html$ / [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Put the root redirect code above the WordPress code like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^pharmacy/?(.*)$ /wp-content/plugins/swift-mailer/lib/classes/$1 [L]
# This will check that the .html is not a true file
# and if so, redirect to root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ / [L,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Note, use R=302 (temporary redirect) until you are satisfied with your redirects. Otherwise, you might have 'permanent' redirects to inadvertent places.
If I understand clearly, your .htaccess now looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^pharmacy/?(.*)$ /wp-content/plugins/swift-mailer/lib/classes/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ / [L,R=301]
RewriteRule . /index.php [L]
</IfModule>
As RewriteCond rules only affect one RewrtieRule below them, this rule
RewriteRule . /index.php [L]
now applies to every request. Simply change your .htaccess to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^pharmacy/?(.*)$ /wp-content/plugins/swift-mailer/lib/classes/$1 [L]
RewriteRule ^(.*)\.html$ / [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I developed an application in a subfolder of my website and it worked fine.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /app/index.php/$1 [L]
</IfModule>
This file was working fine so and index.php was not required to navigate within the application. Now I moved the application to root of website and changes the last line to
RewriteRule ^(.*)$ index.php/$1 [L]
Now I have start getting Internal Server Error 500. I am not sure that it is something I have done or the .htacces is required to be configured differently. It might be an issue with host too, but I want to exhaust my options first.
Any help will be appreciated. Thanks in advance.
if you in root of hosting you just need
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
if you site in folder /foo you need:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /foo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /foo/index.php/$1 [L]
</IfModule>
if still not working try this, for me it works all over:
RewriteEngine On
RewriteBase /foo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /foo/index.php/$1 [L]
I use ISPConfig 3 to manage my domains/subdomains.
I added subdomain parim.kristian.ee which would redirect to web/parim/ (note: web/ is my document root).
ISPConfig generated such redirect to apache config:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^parim.kristian.ee [NC]
RewriteRule ^/(.*)$ /parim/$1 [L]
Now if i'll try to get static resources, such as http://parim.kristian.ee/images/1x1.gif, it serves fine, but when redirect is to codeigniter, it doesn't work.
Htaccess in web/parim/ looks like this:
<IfModule mod_rewrite.c>
RewriteEngine on
Options -Indexes
#Handle CodeIgniter request
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 ./index.php
</IfModule>
NOTE: accessing the same folder via http://kristian.ee/parim/ works!
I s*ck at htaccess, so any help is appreciated.
# To remove index.php from URL
RewriteEngine On
RewriteBase /parim
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Or Simple remove RewriteBase /parim