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
Related
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]
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>
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
I currently use the following htaccess code to remove all .php extensions:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+[^/])/?$ $1.php [L]
ive been trying to use the following htaccess code to internally redirect or add a hidden query parameter to a file
RewriteRule ^myfile/?([^/])?/?$ myfile.php?m=$1 [L]
but it does not work.
Order of rules in .htaccess is important so your new rule should be above all other rules. This should be your .htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^myfile/?([^/])?/?$ myfile.php?m=$1 [L,QSA,NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+[^/])/?$ $1.php [L]
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>