Want to generate redirct rule for htaccess - php

I am having trouble to generate redirection rule I tried so many possible ways but those are not working.
Here are the details:
1) Current link: https://app.abcd.com (Showing in url)
2) Redirect to: https://app.abcd.com/index.php/login
3) Should be renamed as : https://app.abcd.com/login
I have tried :
RewriteEngine on
RewriteRule (.*) http://https://app.abcd.com/index.php/login/$1 [R=301,L]
Didn't work!
Any help!

You can use this :
RewriteEngine on
RewriteRule ^$ /index.php/login [L,R]
This will redirect your homepage / to /index.php/login
You can also accomplish this using RedirectMatch
RedirectMatch 301 ^/$ /index.php/login/

Try it.
Options +FollowSymlinks
Options -Indexes
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteEngine on
RewriteBase /example/
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) index.php/$1 [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)/([^?]*) index.php?_cmd_=$1/$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_cmd_=$1 [L,QSA]

.htaccess for codeigniter:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And in config.php:
change:
$config['index_page'] = "index.php";
to:
$config['index_page'] = "";

HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Open config.php and do following replaces
$config['index_page'] = "index.php"

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
IndexIgnore *

Try to add this in your .htacces file:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]

Related

How to change domain name by .htaccess

I have a domain eg: abc.com. While displaying news the url will be abc.com/news.php?news=xyz. And i want to change the url to something like news.abc.com/xyz.
Is it possible via .htaccess
use this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{HTTP_HOST} !^www.site.com [NC]
RewriteCond %{HTTP_HOST} ([^\.]+).site.com [NC]
RewriteRule ^(.*)$ %1.php?%1=$1 [L,NC]
</IfModule>
use this code in htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ news.php?news=$1 [QSA,L]
</IfModule>

delete index.php file from url - Codeigniter

this is my link :
http://vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/index.php/welcome
I would like to remove index.php from url.
my .htaccess file :
/Pannel
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.vitrinsaz1.ir
RewriteRule ^.*$ http://www.vitrinsaz1.ir%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>
$config['index_page'] = '';
$config['base_url'] = 'http://vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/';
Try this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
for more read this http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/
Add ? after index.php in last rule so your .htaccess would be like
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.vitrinsaz1.ir
RewriteRule ^.*$ http://www.vitrinsaz1.ir%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
You can try this settings ;
$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
$config['base_url'] = '';
And .htaccess ;
<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>
https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html
if it does not work try this link ;
http://www.formget.com/codeigniter-htaccess-remove-index-php/

.htaccess mod rewrite with variable

I am trying to do a simple redirect for my site but I'm having no luck getting it to work.
My .htaccess is:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
RewriteCond %{ENV:LANGUAGE} ^$
RewriteRule (.*) - [QSA,E=LANGUAGE:en]
RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1
RewriteRule ^(.*)$ index.php
I want it to redirect to http://my-site/decorators/profile/whatever if the user browses to http://my-site/profile/whatever
Have your rules like this:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteBase /
RewriteRule ^(profile/.*)$ /my-site/decorators/$1 [NC,L,R=302]
RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
RewriteCond %{ENV:LANGUAGE} ^$
RewriteRule (.*) - [QSA,E=LANGUAGE:en]
RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Add the following htaccess code
RewriteCond ^([profile]+)/(.*)$
RewriteRule ^([decorators]+)/([profile]+)/(.*)$
Remove the following code in your htaccess
RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1

.htaccess RewriteRule error

I have these lines in .htaccess.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Now, I'd like to add the following into the .htaccess, so I can redirect all users to http://www.mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
So, I just added the code above in my existing .htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
RewriteRule . index.php
But, It doesn't work as I expect.
Please teach me how I am supposed to write in this case.
Thanks so much in advance!!
You should redirect to the www subdomain first, then forward the request to your index.php file. Try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.).+$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

PHP url rewriting using htaccess

http://www.example.com/justridesbeta/jstride/vehicle
to
http://www.example.com/justridesbeta/addride
using htaccess.
Currently using
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]
# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
RewriteRule ^[a-zA-Z0-9]+$ justridesbeta/jstride/vehicle
</IfModule>
if ($_SERVER['REQUEST_URI'] == '/justridesbeta/jstride/vehicle')
{
header("Location: http://www.example.com/justridesbeta/addride");
exit;
}
if you really need that

Categories