Magento website shows index.php - magento

I have developed magento site I just want to remove index.php from URL and I did successfully by adding below code in .htaccess
RewriteEngine On<br/>
RewriteBase /<br/>
RewriteRule ^index\.php$ - [L]<br/>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]
But the website is visible, when I'm trying hit https://tumree.com/index.php
In SEO perpective, there shouldn't be duplicate in URL. The two URLs are indexing and its not good.
Please help me to fix the issue...

Related

Redirect subdomain to Post URL

I want to redirect to my post URL when someone visits subdomain of that post name on my site.
Like this
https://www.example.com/sub/mypost ---------> https://mypost.example.com
The site is running on Apache server
So have tried some changes to a .htaccess file
Please not everything is SSL
RewriteEngine on
RewriteCond %{HTTP_HOST} https://$1.example.com [NC]
RewriteRule ^(.*)$ "https://www.example.com/sub/$1" [L,P]
It did not seem working. it redirects to Site cant be reached message on browser.
This is my previos htaccess file before changes.
# 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
Thank You.

.htaccess to provide 'flattened' search engine friendly CMS URLs

I am using CMSMADESIMPLE for a website. It can generate search engine friendly URLs using a .htaccess file and mod_rewrite.
BUT it is possible to insert anything between the base url and the requested page. For example all these URLs will work:
www.example.com/aboutus
www.example.com/home/aboutus
www.example.com/any/rubbish/i/enter/aboutus
I have seen other sites using Wordpress where it is possible to enter the same in the address window, but it will redirect back to the lowest level i.e. www.example.com/aboutus. I would like to achieve the same thing but cannot master .htaccess to do it.
The relevant bits of the .htaccess file are:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
I am assuming that this is something that can be achieved just using mod_rewrite and doesn't require changes to the PHP code within the CMS.
If that's not possible I would like to setup a permanent redirect from some URLs within the CMS which have been indexed by Google.
i.e From www.example.com/home/aboutus to www.example.com/aboutus
I tried adding a RewriteRule to .htaccess without success:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule home/aboutus aboutus [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
Any help appreciated.
Look at the sample htaccess.txt file in the doc folder. There is a section about parent child.
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

How to allow WordPress and Laravel to share top level URLs with htaccess

Edit: This is a major edit of my question, based on feedback in the comments, and a bit of reading on meta.stackoverflow.
I've shifted my goals, now my priority is to route top level URLs between Laravel and WP: I no longer seek to share code / databases / user creds, etc.
Question: What rewrite rules do I need to achieve a URL structure like this:
/ // (home) delivered by WP
/content1 // WP
/content(n) // WP
/dashboard // delivered by Laravel
/widgets/mywidget/ // Laravel
all Laravel pages will be in /admin or /widgets, everything else will be handled by WordPress, including 404s
I will keep WP and Laravel completely separate.
My colleague and I will edit WP using Admin accounts, there will be no other WP users
I will manage presentation for the two apps completely separately
I've setup my files as follows, and have tested that each application works independently of one another. (Ie if Laravel's rewrite rules are the only ones in use, Laravel works fine using laravel-index.php)
From the web root: public_html/
/wordpress
/laravel3 // app dir
/css // these are from the laravel public dir
/images //
/js, etc //
/index.php // WP index.php
/laravel-index.php // laravel's index.php
I'm in a shared hosting environment with no access to httpd.conf.
Here is my .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^widgets - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Laravel
<IfModule mod_rewrite.c>
RewriteRule !^widgets - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ laravel-index.php/$1 [L]
</IfModule>
In this way:
I can reach my WordPress pages, and
WP serves a WP-404 for unknown URLs, but
/widgets gets a vanilla server 404, whilst
/laravel-index.php/widgets displays the proper content.
An additional problem is that WP Dashboard is stealing requests to /dashboard, which I'd like to redirect to Laravel
Thanks for reading!
For WordPress, you need to send all requests that are not in the widgets or dashboard folders to index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond !^widgets
RewriteCond !^dashboard
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
For Laravel, you need to do the opposite, send ONLY requests that are inside widgets or dashboard to laravel-index.php
# Laravel
<IfModule mod_rewrite.c>
RewriteCond ^widgets
RewriteCond ^dashboard
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ laravel-index.php/$1 [L]
</IfModule>

.htaccess "Ignore all rules if link starts with..."

In my root folder I have installed wordpress and there is also my submenu.php that can not be loaded with ajax if I use rules for /%postname%/ (in default )
So this is what WP gave me
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
What do I need to add so that calling
$('#submenu').load('submenu.php?cat=4');
works again?
This is not the way you should be performing AJAX within WordPress.
I suggest you read up on Using AJAX within WordPress from the codex.
I am not really good with htaccess, but this
RewriteRule !^media/ index.php [L]
Will redirect everything except media/* to index, so something like this should work
RewriteRule !^yourscript.php index.php [L]
Note: I agree with Jason there, using it without htaccess is better.

Codeigniter - removing index.php

I downloaded MyClientBase application which is based on code igniter. After the installation, I looked at the MyClientBase's website but the index.php is still there by default.
I tried to remove the index.php using the tips in codeigniter's user guide but it doesn't work.
Is there any solution out there for this issue? Thank you
I use the following .htaccess file to remove index.php. I'm not sure which one the user guide specifies, but I found this to be working perfectly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Also remove 'index.php' from your config.php file. Good luck!
i don't know if it will help but, i use this to remove my index.php from codeigniter url, create a file named .htaccess and put it to your codeigniter folder.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

Resources