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
Related
I have an htaccess file that
Takes care of making for example example.com/fr behave as example.com/index.php?lang=fr
Handles the blog:
--
RewriteEngine On
RewriteCond %{ENV:REDIRECT_rewritten} !=1
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$ [NC]
RewriteRule ^([^/]*)$ /%1/$1? [R=301,L]
RewriteCond %{REQUEST_URI} !^/js/
RewriteRule ^([a-z]{2})(?:/([^/]+))?$ $2?lang=$1 [NC,L,QSA,E=rewritten:1]
#If the following part is removed, it works fine
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
How to fix this?
RewriteBase isn't even needed here because that is applicable for relative paths in .htaccess.
You should keep these rules in site root .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+[^?]*\?lang=([^\s&]+)\s [NC]
RewriteRule ^ /%2/%1? [R=301,L,NE]
RewriteCond %{REQUEST_URI} !^/js/
RewriteRule ^([a-z]{2})(?:/([^/]+))?$ $2?lang=$1 [NC,L,QSA]
And create blog/.htaccess and keep these rules in blog/.htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
I have a website made with wordpress https://example.es/ and I'd like to remove the final slash.
My .htaccess looks like this:
RewriteCond %{REQUEST_URI} !wp-admin
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.es$ [NC]
RewriteCond %{REQUEST_URI} jh73820h.htm$ [NC]
RewriteRule .* - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.es/$1 [R=301,L,QSA]
# 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
I found this code and it removes the final slash but it appears a 404 error.
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !wp-admin
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.es$ [NC]
RewriteCond %{REQUEST_URI} jh73820h.htm$ [NC]
RewriteRule .* - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.es/$1 [R=301,L,QSA]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ https://www.example.es/$1 [R=301,L,QSA]
</IfModule>
# END WordPress
Does anybody know what can I do not to get a 404 error?
Try this:
// BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule (.+)/$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
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 searched how to redirect url with parameters to root dir but I can't get it to work :(
This is what the .htaccess code looks like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteEngine On
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^phpnuke/modules\.php$ /? [L,R=301]
I have url such as "http://www.domain.com/phpnuke/modules.php?name=News&file=article&sid=60" and I want to redirect it to "http://www.diagonally.org/"
Try some thing like this
# For sites running on a port other than 80
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R]
Keep redirect rule before default WP rewrite rule and match correct query string:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} name=News&file=article&sid=60
RewriteRule ^phpnuke/modules\.php$ /? [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
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