i want to ask that when i upload .htaccess file to my hostgator server my one of url is not working
url: email/admin/index.php
the htacces code here:
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.appynator.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^appynator\.com [NC]
RewriteRule (.*) http://www.appynator.com/$1 [L,R=301]
Try changing the first rule to:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php(\?|\ )
RewriteRule ^ http://www.appynator.com/%1 [R=301,L]
Related
I have this rule for redirect from index.php
RewriteCond %{HTTP_HOST} ^(.*):443$ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^/index.php$ [NC]
RewriteRule ^(.*)index\.php$ https://%1/$1 [L,R=301]
But it works only for address: site.com/index.php to site.com
I need to redirect from all adress who contain index.php, for example site.com/categories/rings/index.php to site.com/categories/rings/
Thanks!
Your RewriteCond rules are the problem:
RewriteRule ^(.*/)?index\.php$ https://%{HTTP_HOST}/$1 [L,R=301]
If you want to keep the port RewriteCond, you can use this:
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*/)?index\.php$ https://%{HTTP_HOST}/$1 [L,R=301]
I'm trying to change http://www.mywebsite.com/en/admin/index?page=archived
to
http://www.mywebsite.com/en/admin/page/archived/
I've tried a bunch of things including:
RewriteCond %{QUERY_STRING} ^page=(.+)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/en/admin/%1? [R=301,L]
but i have always a 404 error.
My .htaccess is into admin directory
.htaccess :
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://%{HTTP_HOST}/en/admin/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://%{HTTP_HOST}/en/admin/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
RewriteCond %{THE_REQUEST} /index\?page=(.+?) [NC]
RewriteRule ^index$ /en/admin/page/%1? [NC,L,R]
RewriteRule ^page/([^/.]+)/?$ /en/admin/index?page=$1 [NC,L]
You can use the following code in admin/.htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\?page=([^\s]+) [NC]
RewriteRule ^ /en/admin/page/%1? [NC,L,R]
RewriteRule ^page/([^/.]+)/?$ /en/admin/index?page=$1 [NC,L]
I'm trying to redirect urls from query string using this code:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^?#\ ]*)\?[^\ ]*\ HTTP/
RewriteRule (.+) http://www.example.com/$1? [R=301,L]
This worked well for:
www.example.com/mypage.html?gclid=xxx
But it does not work for:
www.example.com/?gclid=xxx
www.example.com/mypage.html/?gclid=xxx
Also tried unsuccessfully [1]:this answer [question]:Redirecting in HTACCESS from Query String to URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?gclid=([a-z]+)&type=([a-z\-]+) [NC]
RewriteRule ^ /%1/%2? [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?gclid=([a-z]+)($|\ ) [NC]
RewriteRule (.+) http://www.example.com/$1? [R=301,L]
What changes could I do?
thank you very much
after years I discovered a bug in duplication URLs that I try to fix (author is gone) despite htaccess rule I thought should force it.
Issue:
I have the same content under 2 URLS, ex:
http://www.wrock.pl/news-23069/Depeche_Mode_Party_w_klubie_Liverpool_/
www.wrock.pl/index.php?s=news&d=23069&nazwa=Depeche_Mode_Party_w_klubie_Liverpool_
or shorter www.wrock.pl/index.php?s=news&d=23069
Another example are menu pages:
http://www.wrock.pl/koncerty/
www.wrock.pl/index.php?s=koncerty
I thought the "index.php" version should be hidden or redirected to friendly URL version, meanwhile both show with 200/OK
Index.php itself gets redirected OK: www.wrock.pl/index.php
Aim:
be able to show only friendly URl version (redirect the index.php version).
Google stopped indexing them so it may be an issue (one of many reasons).
Here is my htaccess responsible for presented examples:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^wrock.pl(.*) [NC]
RewriteRule ^(.*)$ http://www.wrock.pl/$1 [R=301,L]
# REDIRECT index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.wrock.pl/$1 [R=301,L]
#NEWS
RewriteRule ^news-([0-9]+)/([^-]+)/$ index.php?s=news&d=$1&nazwa=$2 [L,NC]
RewriteRule ^news/([0-9]+)/$ index.php?s=news&strona=$1 [L,NC]
#KONCERTY
RewriteRule ^koncerty/$ index.php?s=koncerty [L,NC]
I dont know if current redirections should be changes or should I enter something like:
#RewriteRule ^index.php?s=news&d=([0-9]+)&nazwa=([^-]+)$ http://www.wrock.pl/news-$1/$2/ [L,NC]
which doesn't work of course.
Thank You very much for any suggestions.
Above your #NEWS items, you need to add these rules:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=news&d=([0-9]+)&nazwa=([^-&\ ]+)($|\ )
RewriteRule ^ /news-%1/%2/ [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=news&strona=([0-9]+)($|\ )
RewriteRule ^ /news/%1/ [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=koncerty
RewriteRule ^ /koncerty/ [L,R=301]
And in order to handle the "shorter www.wrock.pl/index.php?s=news&d=23069":
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=news&d=([0-9]+)($|\ )
RewriteRule ^ /news-%1/ [L,R=301]
RewriteRule ^news-([0-9]+)/$ index.php?s=news&d=$1 [L]
I have the following problem:
http://www.mydomain.com/articles.php?artid=89
should become: http://www.mydomain.com/mykeyword
I dont mind if the id remain in the url...like: http://www.mydomain.com/89/mykeyword
I have the following .htaccess for the moment:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(mydomain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+news\.php [NC]
RewriteRule ^ mykeyword [R=301,L]
RewriteRule ^mykeyword/?$ news.php [L,NC]
The above part works like a charm.
Any help will be deeply appreciated.
Regards, Zoran
Append these rule at the bottom of your .htaccess:
RewriteEngine On
RewriteBase /turkexpo/
RewriteCond %{HTTP_HOST} ^(webone\.gr)$ [NC]
RewriteRule ^(.*)$ http://www.%1/turkexpo/$1 [R=302,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/news\.php [NC]
RewriteRule ^ mykeyword [R=302,L]
RewriteRule ^mykeyword/?$ news.php [L,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/articles\.php\?artid=([0-9]+) [NC]
RewriteRule ^ %1/mykeyword? [R=302,L]
RewriteRule ^([0-9]+)/mykeyword/?$ articles.php?artid=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+turkexpo/companies\.php\?fairid=([0-9]+)&ehallid=([0-9]+) [NC]
RewriteRule ^ companies/%1/%2? [R=302,L]
RewriteRule ^companies/([0-9]+)/([0-9]+)/?$ companies.php?fairid=$1&ehallid=$2 [L,NC,QSA]
This will forward a URI of /89/mykeyword to /articles.php?artid=89 and externally redirect the opposite of it.
Once you make sure it is working change R=302 to R=301.