I'd like to change this url
http://airsviluppo.it/lapolverosa/room/standard-room-one-king-bed/
To this
http://airsviluppo.it/lapolverosa/casali/standard-room-one-king-bed/
By htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lapolverosa/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /lapolverosa/index.php [L]
RewriteRule ^room\/+?$ casali\/
</IfModule>
But doesn't work :(
You can try this .htaccess instead:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lapolverosa/
RewriteRule ^room/(.*)$ casali/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
Related
I am trying de redirect these types of URLs :
https://www.example.com/my-account/VARIABLE-FOLDER/
to
https://www.example.com/my-account/VARIABLE-FOLDER/home/
I am not really familiar with complex redirects with htaccess, can someone help me ?
I tried this but without results :
RewriteRule ^my-account/(.*)$ https://www.example.com/my-account/(.*)$/home/ [R=301,NC,L]
There are all my htaccess rules at the moment :
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Thanks by advance
UPDATE #1, i just tried this :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(mon-compte/.*)/?$ https://vide.ecoles-libres.fr/$1/home/ [R=301,NC,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
And i am now redirected like that :
https://example.com/my-account/VARIABLE-FOLDER/home/home/home/home/home/home/home/home/home/home/home/home/home/home/home/home/home/home/home//home/
With your shown attempts, please try following. Please clear your browser cache before testing your URLs.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)/?$ https://%{HTTP_HOST}/$1 [R=301,NE,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
##Add an additional condition to check about URI here.
RewriteCond %{REQUEST_URI} !/home [NC]
RewriteRule ^(my-account/.*)/?$ https://www.example.com/$1/home/ [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Https redirection is working fine for main website but having problem with the blog. Any of these doesn't work for me.
Test1
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://example.com/blog/$1 [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ /blog/index.php [L]
</IfModule>
Test2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTPS} off
RewriteRule ^blog/(.*) https://example.com/blog/$1 [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ /blog/index.php [L]
</IfModule>
I have downloaded and installed http://www.question2answer.org/ on my website on http://www.yourstartups.com/discussion/ (discussion sub-directory)
Current url structure is like: example.com/index.php?qa=123&qa_1=why-do-birds-sing
I want to change to /123/why-do-birds-sing
(why-do-birds-sing is example query)
Following is my htaccess:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
Can anyone help me?
You need a new rule to rewrite your pretty URL.
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?qa=$1&qa_1=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0 [L,QSA]
</IfModule>
I got a simple Wordpress .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
What i am searching for is how to make the .htaccess be aware in which environment it runs, to change the RewriteBase and RewriteRule accordingly.
Something like (dummy)
if HTTP_HOST == "192.168.0.1" RewriteBase /localfolder, RewriteRule . /local/index.php [L]
else (for all other domains assume online) RewriteBase /, RewriteRule . /index.php [L]
Is there a way to achieve this?
I tried something like
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} =192.168.0.100
RewriteBase /local/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /local/index.php [L]
but don't get it to work. always the first rules are apllied
UPD:
This seems the perfect solution for offline and online:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
This seems the perfect solution for offline and online:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
How can I change my URL from domain.com/sprekers/?spreker=value to domain.com/value with a rewrite rule with wordpress.
I've tried to change it like this
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
than I tested it with the htaccess tester http://htaccess.madewithlove.be If I test it on the tester everything works fine but when I do this on my wordpress site it doesn't work. This is my complete htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
</IfModule>
I think it doesn't work because the /sprekers is already "made" by wordpress how can I fix this?
Cheers
Robin
I think, you need to put your first code after the RewriteBase / rule.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>