redirect htaccess single page with php parameters - .htaccess

I need to redirect 1 single page with .htaccess but i can't figure it out
examp.co/?language=en
should redirect to
examp.co/bla/
the index.php is hidden here because it has already been redirect to root /.

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^language=en(&|$) [NC]
RewriteRule ^$ /bla/? [L,R=301]

Related

redirect url A to url B

I two domains. domainA.co.uk and domainB.co.uk
domainA.co.uk is the main site. this is where all the files are, including the htaccess file
domainB.co.uk is not hosted on the same server, but the DNS A record is pointing to the domainA.co.uk IP address.
Is it possible to redirect domainB.co.uk to domainA.co.uk/page?
On domainB.co.uk pointing host enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.co\.uk$ [NC]
RewriteRule ^ http://domainA.co.uk%{REQUEST_URI} [R=301,L]
Add this to your .htaccess in your web root / directory of domainA.co.uk
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/page [NC]
RewriteRule ^(.*)$ page/$1 [L]

how to redirect index.html to main url in .htaccess

When I access my site via www.domain.com/index.php or www.domain.com/index.html, it needs to redirect to www.domain.com for SEO purposes.
How do I configure this in .htaccess?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(index)|(home)(..{3,4})?$ [NC]
RewriteRule ^([^/]+/)+ http://www.example.com/$1? [R=301,L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
DirectoryIndex index.html index.php
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^index\.(html?|php)$ / [L,R=301,NC]

redirect using htaccess only for specific url

if user hit my_website.com then he should redirect to my_website.com/abc but if he hits my_website.com/xyz then he can visit normally.
How can i do this using .htacess file
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^my_website\.com$ [NC]
Rewriterule ^$ /abc [L,R=302]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.
Try with this
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://my_website.com/abc [L,R=301]

.htaccess redirect non-www to www but leave sub-domains

I want to achieve the following:
http:// domain.com -> http://www.domain.com
http://sub.domain.com -> http:// sub.domain.com(and not http:// www.sub.domain.com)
I have been searching a lot today but can't find a solution. Hope someone helps here.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

remove .php extension with .htaccess for only one directory?

I need to rewrite url only one directory named gallery.
I would like to have abc.com/photos/gallery/picture/ instead of abc.com/photos/gallery/picture.php
.htaccess
index.php
/photos
/gallery
index.php
picture.php
functions.php
/videos
Here is my code to .htaccess but it doesn't work.
RewriteEngine on
RewriteRule ^/[.*]/?$ photos/gallery/$1.php#{QUERY_STRING} [NC,L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /gallery/foo.php to /gallery/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(/+gallery/[^.]+)\.php [NC]
RewriteRule ^ %1 [R=302,L]
## To internally forward /gallery/foo to /gallery/foo.php
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(gallery/.*?)/?$ $1.php [L,NC]

Resources